npub1ap…2mane on Nostr: finally properly clicked for me what "lambdas capture their environment" means, as in ...
finally properly clicked for me what "lambdas capture their environment" means, as in "you can define things in-scope before the lambda is defined, and then those things will be captured in the lambda even after they've gone out of scope"
every example I tried to look at previously just ended up being like verbose syntax vomit
practical gdscript example:
var x := 1
node.example_signal.connect(func(): print(x + 1))
Published at
2024-04-08 17:03:31Event JSON
{
"id": "9be9364517e3d2263616727df3af3ae311acc7a8628d3803e1241b6a281fb5b7",
"pubkey": "e8485d0d064e7e507236576ca9831437be7b01a5b6123d6e1fa469b15c1d149f",
"created_at": 1712595811,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.gamedev.place/users/MenacingMecha/statuses/112236679071780082",
"activitypub"
]
],
"content": "finally properly clicked for me what \"lambdas capture their environment\" means, as in \"you can define things in-scope before the lambda is defined, and then those things will be captured in the lambda even after they've gone out of scope\"\n\nevery example I tried to look at previously just ended up being like verbose syntax vomit\n\npractical gdscript example:\n\nvar x := 1\nnode.example_signal.connect(func(): print(x + 1))",
"sig": "6ed857b9428acb010b6e7de29165d3ae77f568a550fb1c0cc14c33523fabc11d0896e2b87597d4ddcd59e8cdbdc8bab04642679109b73998f0fa7219293aa57e"
}