Skip to content

Instantly share code, notes, and snippets.

View MostafaNasiri's full-sized avatar
🍂

MostafaNasiri

🍂
View GitHub Profile
interface Processor<T> {
fun process(): T
}
class ExampleProcessor : Processor<Unit> {
override fun process() {
// Do something
}
}
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()
}
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"