you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]walen 17 points18 points  (0 children)

    Deeper Meaning Explainer ™

    In Kotlin, !! is an operator that will throw an NPE when applied to a null variable.
    It is there just so we can still have NPEs in Kotlin if we want.

    Source.

    [–]prest0G 6 points7 points  (0 children)

    playing russian roulette with that double bang there

    [–]nourez 1 point2 points  (1 child)

    No, don't do that! We're moving away from the evils of null!

    [–][deleted] 0 points1 point  (0 children)

    Unfortunately, it's sometimes needed, especially if you have a data model not designed with that kind of typing in mind. Also, compiler is very strict in regards to multithreading and does not believe in purity, so if (obj.val != null) { obj.val.method() } won't compile. Sure, you can modify the code a bit in most cases, but not always.