I have a list of items.
Each object has a type (enum).
I want to filter the list and only get items of a certain types. How can I achieve it?
val list = dataList.filter {
when(it.type){
Type.ACTIVE,
Type.RENEWED,
Type.OTHER -> {}
}
}
CodePudding user response:
this should work:
val list = dataList.filter {
when(it.type){
Type.ACTIVE,
Type.RENEWED,
Type.OTHER -> true
else -> false
}
}