From: seebs@... (Peter Seebach) Date: 2007-07-04T09:29:43+09:00 Subject: Re: Using a block to surround a string? In message , "Matt Greer" writes: >And so I take it with blocks, they are given a new reference to the objects >in question and therefore assigning to the variables in the block has no >effect on the method. ie Right. >def around_string(string, &block) > b = nil > a = nil > yield(b,a) > "#{b}#{string}#{a}" >end > >around_string('center') { |b, a| b = 'left'; a = 'right' } > >is worthless because in the block I'm merely assigning objects to local >references that go out of scope once the block exits? Exactly. The block's return in this case is just the string 'right' (the last expression in the block). You could easily do a, b = yield and call with { 'left', 'right' } -s