2006/5/8, Victor Shepelev <vshepelev / imho.com.ua>:
> Hi all.
>
> Here is the code:
>
> str = 'some string'
> blk = lambda{|arg| self.text = str; self.text = arg}
>
> class A
>     def text=(str)
>        #blah
>     end
> end
>
> A.new.instance_eval( &blk )
>
> Questions about the code:
> 1. str would be always visible to block? (Quick tests says yes, but it was
> unexpected for me)
> 2. how can I pass argument to block?

You can as well pass self as argument:

blk = lambda {|it, text| it.text=text}

a=A.new
blk.call a, str

Regards

robert

--
Have a look: http://www.flickr.com/photos/fussel-foto/