CLOVIS
02/20/2020, 5:07 PM.let is map on an Option
?. notation is flatMap on an Option
Your thoughts?streetsofboston
02/20/2020, 5:09 PM?.let and ?. can be a map or flatmap… depends 🙂streetsofboston
02/20/2020, 5:17 PMval value: String? = ...
val size = value?.length
val size = value?.let { it.length }
But, I agree, the ?.let lets you write a flatMap like expression easier:
string2?.let { string1?.concat(it) }
or
string1?.let { it1 -> string2?.let { it1 + it } }
Still, not quite like flatMap 🙂