mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +00:00
16 lines
284 B
Kotlin
Vendored
16 lines
284 B
Kotlin
Vendored
class Foo(
|
|
var state : Int,
|
|
val f : (Int) -> Int){
|
|
|
|
fun next() : Int {
|
|
val nextState = f(state)
|
|
state = nextState
|
|
return state
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
val f = Foo(23, {x -> 2 * x})
|
|
return if (f.next() == 46) "OK" else "fail"
|
|
}
|