mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 15:53:46 +00:00
15 lines
300 B
Plaintext
15 lines
300 B
Plaintext
fun StringBuilder.takeFirst(): Char {
|
|
if (this.length() == 0) return 0.chr
|
|
val c = this.charAt(0)
|
|
this.deleteCharAt(0)
|
|
return c
|
|
}
|
|
|
|
fun foo(expr: StringBuilder): Int {
|
|
val c = expr.takeFirst()
|
|
when(c) {
|
|
0.chr => throw Exception("zero")
|
|
else => throw Exception("nonzero" + c)
|
|
}
|
|
}
|