we need to know the Kotlin language 1st Kotlin is a Statically typed programming language. Kotlin is multiplatform i.e. it runs on JVM, it can be compiled to JavaScript Source code as well as can be used as LLVM backend. Kotlin provides great features and flexibility which enables you to write powerful yet short programs.
to understand the language idioms and features properly, gradually we will move to using Kotlin with Android. P.S. Kotlin has really a huge number of features, here we will focus on most important ones from an Android Developer’s point of view.
change value, val for final variables • Do we really need to declare Datatype explicitly? • Unit and Any • Explicit type casting • Pair val myInt:Int = 15 val name = “Rivu” var myLong:Long = myInt.toLong() var (name,age) = Pair(“Indranil”,24)
Default value • Named arguments • Local functions • Generic functions • Tail recursion made easy tailrec fun isPrime(n:Int =1, div:Int = (n/2)):Boolean = if (div<=1) true else if (n%div == 0) false else isPrime(n,div-1)
Multiple constructors • Diff between init and constructors • Open class • Extension function • Singletons made easy • Data classes • Interfaces • Delegates
(both on Android Studio 2.x and 3) • Simple Hello World with Kotlin • Kotlin Android extension - Say goodbye to butterknife • Anko Library (Commons, Layouts) • Hands on Coding - Notes App