What does this print?
infix fun Int.times2(n: Int): Int {
return this * n * 2
}
fun main() {
val r = 3 times2 4
println(r)
}
Try it in the online Kotlin Playground →
[spoiler title="Solution"]
Answer:
24
Explanation:
Infix functions allow calling with natural syntax between operands.
[/spoiler]