On Wed, Jun 29, 2011 at 11:52 PM, Ryan Davis <ryand-ruby / zenspider.com> wrote:
> I found some online doco about 1.8 -> 1.9 changes that includes this gem:
>
>> x = 1
>> [2,3].each {|y;x| x = y }
>> p x # => 1
>
> It says that ';' declares 'x' as block local. 1.9 warns about the shadowed variable regardless of ',' vs ';', so is this new syntax meaningful at all? I've never seen it used anywhere.
>

I'd say it's meaningful, given the difference in output here (on 1.9,
of course):

a = 1; [2].each { |a| p a }; a              #=> 2; 1
a = 1; [2].each { |;a| p a }; a             #=> nil; 1
a = 1; [2].each { |a| p a; a = 2; p a }; a  #=> 2; 2; 1
a = 1; [2].each { |;a| p a; a = 2; p a }; a #=> nil; 2; 1

The final result is that a == 1 in each case, but inside the block,
the ; makes a difference.