vxh.viet
11/24/2017, 4:04 AM>>> val letters = Array(26) { i -> ('a' + i).toString() }
>>> println(letters.joinToString(""))
abcdefghijklmnopqrstuvwxyz
What exactly is 'a' + i? I've done a little bit of testing and depending on i it will return a character. For example:
println('a' + 2)
c
It seems very basic but I can't find any more detail explanation for this.russhwolf
11/24/2017, 4:09 AM'a'.plus(2), ie calling into this function: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char/plus.htmlrusshwolf
11/24/2017, 4:10 AMvxh.viet
11/24/2017, 4:12 AMoperator function in Char.kt. It a little bit confusing at first since there's no implementation detail.vxh.viet
11/24/2017, 4:12 AM/** Adds the other Int value to this value resulting a Char. */
public operator fun plus(other: Int): Charrusshwolf
11/24/2017, 4:15 AMchar (ie the ascii value), adds the other int to it, and returns the char associated with that index.