Mathieu asks and matz answers:
> |Sorry, I tried both of the following and I cannot find a
> |difference in results. Maybe you can enlighten me?
> 
> |1.   buff = File.open("/etc/hosts") {|f| f.read() }
> |
> |2.   File.open("/etc/hosts") {|f| buff = f.read() }
> 
> Thechenically they are same, but appearance makes difference.

I'm sorry, I'm not following the idea of sameness here.

1) Works as I expect:

  ruby -ve'buff = File.open("menu.sav") {|f| f.read()}; puts buff'
  ruby 1.6.2 (2000-12-25) [i686-linux]
  ...

2) I would expect buff to become local variable scoped in the block, thus
not seen from the outside (after the block).

  ruby -e'File.open("foo") {|f| buff = f.read()}; puts buff'
  -e:1: undefined local variable or method `buff' for
        #<Object:0x401c4c90> (NameError)

With a small modification of Dave's we bring buff in existence before
the block and then the assignment really changes where buff points. Then
we can see the changed buff after the buff also.

  ruby -e'buff=""; File.open("menu.sav") {|f| buff = f.read()}; puts buff'
  ...

Does this clear things at all, or am I a prisoner of my own thoughts?

    - Aleksi