The general idea that you have to understand is that in Snap!, as in most programming languages, inputs to a procedure are evaluated before the procedure is called. (The fancy name for this rule is “applicative order.”) That is, when you say
, the SAY block knows only that its input value is 5, not that there was a + block involved in its computation.
Now apply that idea to the SET block. If you say
the input
Now, in Snap! there’s a way to use a piece of code as a value, namely, you put it in a ring.
So this:
does what you want.
By contrast, the SET VAR library block wants a variable name, an ordinary text string, as its input. So neither
nor
will do; you need the word “a” as the input:
![]()
As it happens, Snap! provides a way to get the names of all the variables accessible to a script:
Bottom line: You have to think about applicative order evaluation, and you have to think about what kind of thing each of SET and SET VAR wants as input, and then you can work out the meaning of all your example scripts.





