pavel
11/06/2018, 12:07 AMval foo = listOf("foo", "bar", null, "")
val bar = foo.filter { !it.isNullOrEmpty() }
the compiler is arguing that bar is List<String?> while my position is that it should be List<String>. Am I expecting too much from contracts? And is there a better way to write this?Shawn
11/06/2018, 12:15 AM((T) -> Boolean) -> T, which makes transforms to the non-null version of T kind of a higher effort thinglouiscad
11/06/2018, 12:16 AMval foo = listOf("foo", "bar", null, "")
val bar: List<String> = foo.asSequence().filterNotNull().filter { it.isNotEmpty() }.toList()Shawn
11/06/2018, 12:16 AM.filterNotNull() and then .filter(String::isNotEmpty)Shawn
11/06/2018, 12:17 AMpavel
11/06/2018, 12:17 AMpavel
11/06/2018, 12:17 AMval bar = foo.filterNotNull().filterNot { it.isEmpty() }pavel
11/06/2018, 12:18 AMShawn
11/06/2018, 12:19 AMShawn
11/06/2018, 12:19 AM.filterNotNullAnd { ... }louiscad
11/06/2018, 12:20 AMpavel
11/06/2018, 12:21 AMkarelpeeters
11/06/2018, 12:27 AMpavel
11/06/2018, 12:27 AMspand
11/06/2018, 11:09 AMmapNotNull