Difference between revisions of "@ operator"
Jump to navigation
Jump to search
(Created page with "Normally in MiniScript, whenever a variable a used in an expression, if it refers to a function, that function is automatically invoked. The <c>@</c> operator suppresses this...") |
m |
||
| Line 12: | Line 12: | ||
f // invokes f again, printing a DIFFERENT result | f // invokes f again, printing a DIFFERENT result | ||
</ms> | </ms> | ||
| + | |||
| + | [[Category:Language]] | ||
Latest revision as of 02:23, 30 January 2025
Normally in MiniScript, whenever a variable a used in an expression, if it refers to a function, that function is automatically invoked. The @ operator suppresses this invocation, allowing you to work with a function reference without invoking it.
Example
Try the following at any interactive MiniScript REPL:
f = rnd // makes f contain the result of calling [[rnd]]
f // prints that result
f // prints that SAME result again (f is just a number
f = @rnd // makes f refer to the [[rnd]] function
f // invokes f, and prints a random number
f // invokes f again, printing a DIFFERENT result