
Posted by Shinisuryu on Tue, 20 Jul 2010 14:29:11
I know the basics of giving a variable a value, but I've seen something that I'm not totally sure I understand.
Blah1 = (Blah2 == 0 and Blah3 or Blah2)
Now, is the first part just like a if comparison? and if not, where would I figure out how that process works?
Sorry if this is kind of confusing, I've been stuck for a bit, trying to figure out this. x.x

Posted by jnwhiteh on Tue, 20 Jul 2010 15:07:11
I know the basics of giving a variable a value, but I've seen something that I'm not totally sure I understand.
Blah1 = (Blah2 == 0 and Blah3 or Blah2)
Now, is the first part just like a if comparison? and if not, where would I figure out how that process works?
Sorry if this is kind of confusing, I've been stuck for a bit, trying to figure out this. x.x
This sort of construction is covered in Chapter 2, when we discuss the boolean
and
andor
operators. Fully expanded, it's doing roughly the following:if Blah2 == 0 then Blah1 = Blah3 else Blah1 = Blah2 end
This is accomplished using the short circuit evaluation of bolean expression. More information can be found here and here.

Posted by Shinisuryu on Tue, 20 Jul 2010 15:15:39
Oh wow, that makes so much more sense now. Thanks! ( I am so buying this book asap. )