Does it ever make sense to use double-bang (!!) af...
# announcements
v
Does it ever make sense to use double-bang (!!) after safe operator (?.) in a kotlin expression, considering non-nullable properties of a nullable receiver are nullable?
Copy code
class Foo(val bar: Bar)
var foo: Foo? = null 
foo?.bar!! // will crash when foo is null đŸ’€
p
This code will throw exception when foo is not null but bar is null.
v
that’s true, but my point was it’ll also throw exception when foo is null and bar is not
updated the snippet to make it clear
p
when foo is null. Foo.bar will also be null. I don't think it's possible to have non null member when object itself is null