Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- SQL
- mybatis
- JavaScript
- mapreduce
- window
- hadoop
- Express
- Kotlin
- Android
- 정렬
- Python
- IntelliJ
- 보조정렬
- SPC
- Eclipse
- NPM
- maVen
- es6
- 공정능력
- react
- table
- Spring
- MSSQL
- GIT
- tomcat
- Sqoop
- R
- xPlatform
- Java
- vaadin
Archives
- Today
- Total
DBILITY
독거 가능성 100% 노후에 라면값이라도 하게 센스를 발휘합시다!😅
Please click on the ad so that I can pay for ramen in my old age!
点击一下广告,让老后吃个泡面钱吧!
老後にラーメン代だけでもするように広告を一回クリックしてください。
kotlin reduce, fold 본문
반응형
empty colletion일때 reduce는 오류가 발생한다.
java.lang.UnsupportedOperationException: Empty collection can't be reduced.
가능성이 있을때는 fold를 사용해도 되나?^^
data class Todo(val id: Int, val content: String, val datetime: Long)
...
private val initDataList = mutableListOf<Todo>()
/*val maxId = fold(Todo(0, String(), 0L)) { acc, todo ->
if (acc.id.compareTo(todo.id) == 1) acc else todo
}.id + 1*/
var maxId = 1
if (size>1) {
maxId = reduce { acc, todo ->
if (acc.id.compareTo(todo.id) == 1) acc else todo
}.id + 1
}
반응형
'android' 카테고리의 다른 글
안드로이드 dp, dip, sp, sip, dpi , px 등 (0) | 2024.03.11 |
---|---|
안드로이드 RecyclerView 기초 사용법 ( viewMoldel update 적용 ) (0) | 2024.03.11 |
안드로이드 RecyclerView 기초 사용법 ( viewMoldel 적용 ) (0) | 2024.03.07 |
안드로이드 TOML (0) | 2024.03.07 |
안드로이드 RecyclerView 기초 사용법 (0) | 2024.03.05 |
Comments