Automatic casting of variables?
Posted: Jul 14th, '17, 10:39
Hey :)
Snap automatically casts variables (or rather, resets them to a default value of the target data type):
if you set a variable x to "hello", and then increase the value of x by 5, the result comes out as 5.
In GP, currently, this results in a syntax error thrown by the debugger (see attachment) .Is this because automatic casting is not yet implemented, or is it a deliberate decision? GP does have other forms of explicit casting, like the "to string" and "to number" blocks, so I imagine it could very well be an intentional design choice.
Snap automatically casts variables (or rather, resets them to a default value of the target data type):
if you set a variable x to "hello", and then increase the value of x by 5, the result comes out as 5.
In GP, currently, this results in a syntax error thrown by the debugger (see attachment) .Is this because automatic casting is not yet implemented, or is it a deliberate decision? GP does have other forms of explicit casting, like the "to string" and "to number" blocks, so I imagine it could very well be an intentional design choice.