Lambda Definition (Section) — skLambda

Addon: skLambda · Category: Section · Since: 0.0.1-alpha

Syntax

set %~object% to lambda[ <.+>]

Description

Defines a lambda and assigns it to a variable. The lambda closes over the local variables (`{_x}`) in scope where it is defined: a snapshot is taken at definition time and is readable inside the body when the lambda is later called. Parameters shadow any captured local of the same name. The snapshot is by value, so laterchanges to the outer local are not seen, and changes inside the body don't leak out.

Examples

set {_double} to lambda (n: number) -> number:
	return {_n} * 2

set {_greet} to lambda (p: player):
	send "Hello %{_p}%!" to {_p}

set {_now_ms} to lambda -> number:
	return unix timestamp of now

View source