From: Jean-Hugues ROBERT Date: 2002-06-13T19:26:00+09:00 Subject: Re: Trick or Bug? At 07:48 13/06/2002 +0900, you wrote: >On Wednesday 12 June 2002 01:02 pm, Hal E. Fulton wrote: > > ----- Original Message ----- > > From: "Nikodemus Siivola" > > To: "ruby-talk ML" > > Sent: Wednesday, June 12, 2002 5:26 AM > > Subject: Trick or Bug? > > > > > All this talk of block local variables reminded me of a funny trick... > > > > > > As you know, receivers in ruby cannot change their class? No become, etc. > > > Right? > > > > > > Wrong: > > > > > > #!/usr/bin/env ruby > > > a = proc { a = 1 } > > > puts "a is a #{a.class}" > > > a.call > > > puts "a is a #{a.class}" > > > > Clever, but not correct, I think. > > You've just pointed 'a' to a > > different object, not changed the > > class of the original object. > > > > As I understand 'become' in Smalltalk > > (and I don't really) doesn't it > > operate on an object? > >I never used it. But if I remember correctly it changes ALL references to >the >old object to a new object. > > > > Hal Fulton ALL, that's pretty frightening ! I guess that most of the time when I was referring to "become" so far I should have used "become_a" instead. 'a.become_a X; assert a.type == X' Thanks for the clarification. Yours, Jean-Hugues ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17