latest version of everything. They all have to sync. Only minor hiccups around version updates: - JDK - Kotlin - Android Support libs - Gradle - 3rd Party - Annotations
early June. Will all hiccups magically disappear? Plausible! It will at least be fewer problems with syncing since Android Studio will bundle everything in a controlled manner.
early June. Will all hiccups magically disappear? Plausible! It will at least be fewer problems with syncing since Android Studio will bundle everything in a controlled manner. Unless you use the early access builds… ;)
(api 24) has some Java 8 support “To test lambda expressions, method references, and type annotations on earlier versions of Android, go to your build.gradle file, and set compileSdkVersion and targetSdkVersion to 23 or lower. You will still need to enable the Jack toolchain to use these Java 8 features.”
class Kotlin { fun send( message:String ){ // message is not nullable so we // don’t handle nulls } } // java public class Java { private String name; public Java( Kotlin instance ) { // No compile error instance.send( name ); } }
Auto-convert It’s getting a lot better but not good. You’ve got the foundation but then you should really refactor it. - Don’t make data classes for you - A lot of !! and ? to reflect the java code but often you can alter that - Copy paste from one language into the other usually works from Java to Kotlin but not the other way around.
fun brake() } class Turbo(val topSpeed:Int):Engine { var speed = 0 private set override fun gas() { speed = topSpeed } override fun brake() { speed = 0 } } class Car( e:Engine ):Engine by e val turboCar = Car( Turbo( 300 ) ) turboCar.gas()
data class Person( val name:String, val age:Int ) val bob = Person( “Bob”, 33 ) operator fun Person.plus( inc:Int ) = copy( age = age + inc ) operator fun Person.plus( n:String ) = copy( name = “$name $n” ) bob + 2 // Person(name=Bob, age=35) bob + “D” // Person(name=Bob D, age=33)
a + b // a.plus(b) a - b // a.minus(b) a % b // a.rem(b) a..b // a.rangeTo(b) a += b // a.plusAssign(b) a in b // b.contains(a) a !in b // !b.contains(a) a > b // a.compareTo(b) > 0 a == b // a?.equals(b) ?: (b === null) a() // a.invoke()