With introduction of Kotlin as official language for Android development at Google I/O 2017, we have…
I decide to start to write some small and quick code pills to help to understand how Kotlin works.
As you know, Kotlin works on JVM and most of developers are friendly with Java, that’s why I will use Java to help to show concept of Kotlin.
In Kotlin , one of the option is the safe call operator, written with ?.
?.
var b: String? = null
println(b?.length)
Prints b.lenght if b is not null, otherwise prints null.
b.lenght
b
I’ve been working with Kotlin for a little over a year. From writing tutorials about Kotlin to giving talks at local meet-ups and conferences, it’s safe to say I at least feel comfortable with the language. One thing I never fully…
One of the major selling points about Kotlin is the ability to avoid the dreaded NullPointerException(NPE), also known as The Billion Dollar Mistake. Kotlin solves this problem by having a type system which can represent both nullable (indicated by…
NullPointerException
In Kotlin, val and var are the two keywords you can use to declare variables.
val
var
val is using for Read-Only local variables definition. Means immutable, you can assign only once, which is same as final in Java.
final