Android ● ○ ○ Kotlin 2.0

Kodebits Day 90: Named Arguments

Sep 10 2026
Practice arguments with a short kotlin challenge.

What does this print?

fun calc(
  a: Int, b: Int, op: String
): Int {
  return if (op == "+")
    a + b else a - b
}
fun main() {
  println(calc(
    b = 5, a = 3, op = "+"
  ))
  println(calc(
    op = "?", a = 3, b = 5
  ))
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

8
-2

Explanation:

Named arguments allow reordering and clarity.

[/spoiler]


Further Reading