"Hal E. Fulton" <hal9000 / hypermetrics.com> writes:

> > |I'm not sure I understand why we'd want to change the '|...|' to
> > |"<...>". If we don't need to use '<...>' for lexical reasons, wouldn't
> > |it be better to use '|...|'? That way we'd leave the '<..>' option
> > |free for use for some other purpose in future.
> > 
> > No, the idea was *not* changing, but providing both. '|...|' is for the
> > current block parameters, which is processed by multiple assignment.
> > And '<...>' is for function-like parameters, which is processed just
> > like method arguments.
> 
> In that case, what does the semicolon mean?

It separates parameters from variables which are local to the block.


    a = 1
    i = 2
    (1..10).each do |i|
      a = i*i
    end

    p a   #=> 100
    p i   #=> 10
 
...

    a = 1
    i = 2
    (1..10).each do |i;a|
      a = i*i
    end

    p a   #=> 1
    p i   #=> 10

and I assume

    a = 1
    i = 2
    (1..10).each do <i;a>
      a = i*i
    end

    p a   #=> 1
    p i   #=> 2



As a somewhat tongue-in-cheek alternative (which breaks backwards
compatibility) we could have 'do!' which inherits variables from the
enclosing scope and 'do' which doesn't...



Dave