https://kotlinlang.org logo
s

stephanc

04/17/2018, 8:28 AM
@karelpeeters lol, but some people just convert their java code and don't change anything 😛. But yeah, we shouldn't give too many tools that can be abused. Thus, the super elvis operator opens pandora's box too much and is way too overkill. However, it isn't completely clear from the kotlin docs that kotlin's safe call is not like C#'s null propagation. So in Kotlin you will have to write a few extra
?
, at least there is scoping functions as well that limits this.
i

ilya.gorbunov

04/17/2018, 12:32 PM
However, it isn't completely clear from the kotlin docs that kotlin's safe call is not like C#'s null propagation.
This was discussed earlier here https://discuss.kotlinlang.org/t/foo-bar-yolo-stop-mixed-nullable-non-nullable-call-chain/5506 In short safe calls cannot be short-circuited, because there could be extension functions on nullable receivers in a call chain, like
String?.isNullOrEmpty()
Perhaps we can improve docs in this section http://kotlinlang.org/docs/reference/null-safety.html#safe-calls to make it more clear
s

stephanc

04/17/2018, 1:31 PM
Cool thanks for that link explaining why, maybe just make it more clear with some more examples of using let, but also if else for null checks 🙂. So that all the different ways of handling this type of thing is clearly laid out.
3 Views