In Event docs, what is '#{ }' syntax?

https://doc.sccode.org/Classes/Event.html

You can find those syntax usages at bottom of the page.

#[a, b, c] is the literal array.
Then those are kind of literal function?? :sweat_smile:

Thx.

It’s a closed function (one that has no references to variables outside its own scope).

(
var abc;

// an open function
{ |def| abc + def }

// a closed function
#{ |def| def * 2 }

// without the #, it still compiles as a closed function
{ |def| def * 2 }

// but an open function with # produces an error
#{ |def| abc + def }

So the # is kind of a reminder to keep it a closed function – if you accidentally change it to use outside variables, it will complain.

hjh

1 Like

Thank you very much!