Android

[Kotlin] ์ฝ”ํ‹€๋ฆฐ Array ์กฐ๊ฑด ๊ฒ€์ƒ‰ ๋ฉ”์†Œ๋“œ (any / all)

Forest Yun 2021. 6. 18. 18:10
728x90

any

any ๋ฉ”์†Œ๋“œ๋Š” ์›์†Œ ํ•˜๋‚˜๋ผ๋„ ๋žŒ๋‹ค์‹์— ํ•ด๋‹นํ•˜๋ฉด true๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

val array:Array = arrayOf(10, 30, 27) 
val boolArray:Boolean = array.any{ array-> array<20 } 
//boolArray ๋Š” true

 

all

all ๋ฉ”์†Œ๋“œ๋Š” ๋ชจ๋“  ์›์†Œ๊ฐ€ ๋žŒ๋‹ค์‹์— ํ•ด๋‹นํ•ด์•ผ true ๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

val array:Array = arrayOf(10, 30, 27) 
val boolArray:Boolean = array.all{ array-> array<20 } 
//boolArray ๋Š” false

โ€‹

โ€‹

โ€‹

โ€‹

https://ponyozzang.tistory.com/518

all , any

https://zerogdev.blogspot.com/2019/07/kotlin-filter-map-all-any-count-find.html

์ฝ”ํ‹€๋ฆฐ ๋ฉ”์†Œ๋“œ(filter, map, all, any, count, find, groupBy,flatMap)

728x90