This is (should be) the exact equivalent of the Cilia code in Kotlin:
- Types
Int,Long,Float
- Variables
var x: Int = 42var x = 42val x = 42var words: MutableList<String> = mutableListOf()var names: MutableSet<String> = mutableSetOf()var contactInfoForID: MutableMap<String, ContactInfo> = mutableMapOf()
- Functions
fun multiply(a: Int, b: Int): Int { return a * b }fun print(a: ContactInfo) { ... }fun concat(a: String, b: String): String { return ... }
- Loops
for (i in 1..10) { ... }for (i in 0 until words.size) { ... }for (i in listOf(5, 7, 11, 13)) { ... }for (word in words) { ... }
Note
In KotlinIntand42are 32 bits wide, not 64 bits.
AnArrayhas a fixed size.