On Tue, Nov 8, 2011 at 10:22, Fily Salas <fs_tigre / hotmail.com> wrote:

> Sorry about the confusion, I was talking more about pipes used in a
> block something like "|hobby|" in the code below.
...
>>hobbies.each do |hobby|

Oh!  That's different.  I thought you mainly meant the ||= trick.

> Is this the only time where "||" will not act as a boolean symbol?

As someone else pointed out, there are some times when Ruby will let
you use pretty much anything as delimiters, but even then:

> If this is a local variable why not use paranthesis as follow...
...
>>hobbies.each do (hobby)

If Ruby allowed us to use arbitrary delimeters here, parens wouldn't
work because they don't match.  That is, the opener is different from
the closer.  Arbitrary delimiters might let you do something like
"hobbies.each do (hobby(", but that would be even worse.  :-)

You're right that introducing a new syntax for what are essentially
arguments, adds a bit more to what a newbie needs to learn.  Parens
would make it more obvious.  I suspect that one reason parens aren't
used there, is that you can often omit the block args if they're not
going to be used, and parens could look like an expression that you
want evaluated.

> Again my main confusion is because I have never seen double pipes used
> other than as Booleans, why are they used to enclose a local variable?

Don't think of it as double pipes, just think of it as two single
pipes.  And don't get started on applying them as bit-wise ORs.  ;-)

-Dave

-- 
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)