Kulwinder Singh
06/26/2018, 5:09 AMcriteria
i don't understood that part, please explainjon.peterson
06/26/2018, 5:11 AMKulwinder Singh
06/26/2018, 5:12 AMKulwinder Singh
06/26/2018, 5:13 AMjon.peterson
06/26/2018, 5:19 AMikt
06/26/2018, 7:19 AMmplacona
06/26/2018, 9:44 AMreduce
.
What would you expect this to print?
val fruitBasket = listOf("banana", "cherry", "orange", "apple", "banana", "cherry", "orange", "apple", "fig", "cherry")
fruitBasket.reduce { acc, s ->
println(s)
acc
}
edwardwongtl
06/26/2018, 9:48 AMmplacona
06/26/2018, 9:48 AMedwardwongtl
06/26/2018, 9:49 AMreduce
takes the first item as the first acc
gildor
06/26/2018, 9:49 AMedwardwongtl
06/26/2018, 9:50 AMacc
, so the first one is missing.mplacona
06/26/2018, 9:50 AMfold
instead, it would print the first value as I'd pass an initialiser right?edwardwongtl
06/26/2018, 9:50 AMmplacona
06/26/2018, 9:51 AMval fruitBasket = listOf("banana", "cherry", "orange", "apple", "banana", "cherry", "orange", "apple", "fig", "cherry")
fruitBasket.fold(0) { acc, s ->
println(s)
acc
}
edwardwongtl
06/26/2018, 9:51 AMedwardwongtl
06/26/2018, 9:52 AMfold
also let you collapse into a different type, while reduce
can only be the same type as the List
mplacona
06/26/2018, 9:52 AMDaniele Segato
06/26/2018, 10:14 AMcall
and concatenate directly after when
?
Something like this pseudo code
return when (it) { ... }?.subscribeOn(<http://Schedulers.io|Schedulers.io>())?.toObservable() else Observable.empty<String>()
user
06/26/2018, 10:15 AMedwardwongtl
06/26/2018, 10:46 AMreturn when() {}
is validedwardwongtl
06/26/2018, 12:24 PMwhen
Michael
06/26/2018, 2:36 PMit.baz
is nullable (probably a java pojo); the definition is myfunc <T> (func Function<Foo, T>) : T?
Ron K
06/26/2018, 2:44 PMMap
to ruby, then I get back a java-Map
, when I invoke some funktion in ruby. When I constuct a hash in ruby, it's a RubyHash
passed back to kotlin. Now, since both types are possible and a RubyHash
does not derive from java-Map
, I get the (TypeError) failed to coerce java.util.LinkedHashMap to org.jruby.RubyHash
error. Can I attack this with kotlin?ikt
06/26/2018, 4:31 PMikt
06/26/2018, 4:32 PMikt
06/26/2018, 4:41 PMkarelpeeters
06/26/2018, 4:42 PMikt
06/26/2018, 4:44 PMkarelpeeters
06/26/2018, 4:44 PM