ChrisKaelin
4/20/2007 10:30:00 PM
On 20 Apr., 22:24, Brian Candler <B.Cand...@pobox.com> wrote:
> On Sat, Apr 21, 2007 at 04:10:09AM +0900, ChrisKaelin wrote:
> > - Why can't I use "ids.each" instead of "for id in ids"? Ok, this
> > question has nothing to do with the code itself ;-)
>
> ids.each do |id|
> ...
> end
nope, that gives me:
SyntaxError: compile error
(irb):3: syntax error, unexpected kDO
(irb):13: can't find string "EOF" anywhere before EOF
(irb):4: syntax error, unexpected $end, expecting tSTRING_CONTENT or
tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
from (irb):4
from :0
while " for id in ids" works well (that's why the official code uses
it, I guess. Normally "each" is preferred over that, afaik.
> > - I know what "||=" does (evaluate assignment only, if the left part
> > is false), but what do you call this?
>
> Note that
>
> a ||= b
>
> is syntactic sugar for
>
> a = a || b
>
> My K&R C book just calls them "assignment operators", although C doesn't
> have ||= (but it has *=, /=, %=, +=, -=, <<=. >>=, &=, ^=, |=)
my fault, I should've known that, I just only knew ||= from Array
stuff, so I could not get the link to a = a || b. Thanks a lot!