mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 09:14:46 +01:00
24 lines
298 B
Plaintext
24 lines
298 B
Plaintext
fun returnCallable(a) {
|
|
return x -> x * a
|
|
}
|
|
|
|
let double := returnCallable(2)
|
|
let triple := returnCallable(3)
|
|
|
|
print(double(2)) // 4
|
|
print(triple(2)) // 6
|
|
|
|
print('----------')
|
|
|
|
fun outer() {
|
|
let x := 'outside'
|
|
fun inner() {
|
|
print(x)
|
|
}
|
|
|
|
return inner
|
|
}
|
|
|
|
let closure := outer()
|
|
closure()
|