0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-21 13:39:22 +01:00
posthog/hogvm/__tests__/lambdas.hog
2024-08-29 14:28:50 +02:00

38 lines
564 B
Plaintext

let b := x -> x * 2
print(b)
print(b(2))
print(b(8))
print('--------')
let func := x -> x * 2
let arr := [func]
print(func(2))
print(arr[1](2))
print((x -> x * 2)(2))
print('--------')
let withArg := x -> {
print(x)
print('moo')
print('cow')
}
withArg(2)
print('--------')
let noArg := () -> {
print('moo')
print('cow')
}
noArg()
print('-------- lambdas do not survive json --------')
print(b)
print(jsonStringify(b)) // just a json string "<lambda:0>"
let c := jsonParse(jsonStringify(b))
print(c) // prints a string, can't be called