On 1/9/08, Radosw Bu„Šat <radek.bulat / gmail.com> wrote:
> > Has this changed in 1.9, or is it anticipated to change in 2.0 ?
>
> With small change (added .to_s method)
>
> $ cat proc.rb
> ###########################
> y=5
> print "y: " + y.to_s + "\n"
> text_at_the_end = lambda do |y|
>  print y + " text at the end\n"
> end
>
> print "y: " + y.to_s + "\n"
>
>
> def oneparam
>  yield("oneparam")
> end
>
> oneparam(&text_at_the_end)
> print "y: " + y.to_s + "\n"
>
>
> ########################
>
> $ ruby1.8 proc.rb
> y: 5
> y: 5
> oneparam text at the end
> y: oneparam
>
> $ ruby1.9 proc.rb
> y: 5
> y: 5
> oneparam text at the end
> y: 5

And if you use the -w option ruby 1.9 will warn that the semantics have changed.

$ ruby1.9 -w proc.rb
proc.rb:4: warning: shadowing outer local variable - y
y: 5
y: 5
oneparam text at the end
y: 5

$ ruby -w proc.rb
y: 5
y: 5
oneparam text at the end
y: oneparam


-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/