From: "ara.t.howard" Date: 2008-01-07T02:20:46+09:00 Subject: Re: Programmatically creating a local variable using a symol On Jan 6, 2008, at 9:34 AM, tho_mica_l wrote: > nice if it could look somewhat like this: > > val = Foo(1, 2) > > case val > when Foo(:x, :y) > a = x * y > when Bar(:x) > a = x > end invert the var binding: make them instance variables and it falls out easily: class Foo attr :x, :y def initialize x, y @x, @y = x, y end end def Foo(*a, &b) Foo.new(*a, &b) end class Bar < Foo; end def Bar(*a, &b) Bar.new(*a, &b) end val = Foo 1, 2 a = case val when Foo val.x * val.y when Bar val.x end a @ http://codeforpeople.com/ -- share your knowledge. it's a way to achieve immortality. h.h. the 14th dalai lama