News for hackers. Stuff that matters.
Re:Love for TypeScript by tomjen3 on Saturday July 30, 2016 @03:51AM (#12192067)
Kotlin can do something similar, in fact I think the code would work exactly like that if you ported it, but it can also do things like:

> if (a instanceOf SomeClass && a.someGetterOnSomeClassNotAvailableOnTheStaticTypeOfa != null)

Which is pretty awesome because it means you don't have to pollute your code with unnecessary casts.

Re:Love for TypeScript by cel1ne on Saturday July 30, 2016 @04:16AM (#12192133)
Kotlin has compile-time null-safety. The ? denotes a type than can be null.

    fun myFunction(x: Number?) {
       if (x == null) return;
       print(x + 1);
    }
if you don't check for null first the compiler warns.

You can also do:

    x?.let {notNullX -> print(notNullX + 1)}
or

    print((x ?: 4) + 1)
https://kotlinlang.org/docs/reference/null-safety.html

It really is an awesome language. Especially the delegated properties are wonderful. I use them to fill javascript-state for redux/react-native.