tiffy wrote:With the first two raw examples, I only wanted to put forward the idea in the hope that the more competent Ruby programmers will / can take it a step or two further in some practical examples and also share some of their practical ideas on this.
More of an observation than an example - that with the addition of Ruby, FlowStone now has three different definitions of what a boolean is! In 'green', zero = false and non-zero (but usually one) = true, but in DSP/Assembly, zero is still false, but true is an "all-bits" bitmask that isn't even a real number. And now, in Ruby, only nil/false are false, and absolutely anything else counts as true!
I must admit that when sending a value to a RubyEdit boolean output, the way that the value is translated almost as if it's a 'green' value caught me out a few times - I expected that it would just use the Ruby definition (equivalent to the !!-trick.)
Maybe worth pointing out too, that
within Ruby code (i.e. not when sending to an output), you very rarely need the !!-trick. For control statements like
if,
unless,
while,
until, the conversion is always implied - so people shouldn't panic and go through all their Ruby code adding lots of exclamation marks. However, when you're expecting a boolean RubyEdit output to do what you want, or absolutely need true/false in the code, it's very handy indeed!