This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Processor<T> { | |
fun process(): T | |
} | |
class ExampleProcessor : Processor<Unit> { | |
override fun process() { | |
// Do something | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val anInt = 2 | |
val aLong: Long = anInt // Error: Type mismatch | |
aLong = anInt.toLong() // This is correct | |
val stringNum = "123" | |
val num = stringNum.toInt() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
var city: String = "New York" | |
// You can omit the type if you declare and initialize a variable at the same time | |
var city = "New York" | |
// But you can't do something like this: | |
var city // Error: Either specify the variable type or initialize it | |
city = "New York" |
NewerOlder