Mark
11/30/2018, 7:23 AMif (arg == null) null else myfun(arg)? I can only think of arg?.let { myfun(it) } ?: null but this seems less readable to me.gildor
11/30/2018, 7:24 AMarg?.let(::myFun)
You don’t need ?:Mark
11/30/2018, 7:26 AMarg?.let { myfun(it) } so would let be the appropriate function to use?gildor
11/30/2018, 7:26 AMgildor
11/30/2018, 7:27 AMMark
11/30/2018, 7:29 AMMyArgClass.myfun() = this?.let {myfun(this)} so I can then do arg?.myfun()?Mark
11/30/2018, 7:30 AMgildor
11/30/2018, 7:30 AMtoSomething functions, including stdlibMark
11/30/2018, 7:35 AMmyfun() accept a null arg and return null in that case. Is there some general way (contracts?) that a function can declare that a null arg will return null result?voddan
11/30/2018, 7:43 AMnull it should deal with it more intelligently than returning another null immediately. In your situation an extension on a not-null type is the most obvious way IMO arg?.myFunc()hmole
11/30/2018, 1:38 PMrun instead of let looks more concisegildor
11/30/2018, 2:04 PM