From: Jim Freeze Date: 2003-01-06T20:36:45+09:00 Subject: Re: attr_cast, one a small step for interface techniques On Monday, 6 January 2003 at 17:48:18 +0900, Tom Sawyer wrote: > On Sunday 05 January 2003 09:30 pm, Gavin Sinclair wrote: > > Those both being annoyingly long, I would prefer an implementation > > that allowed: > > > > attr_accessor :x, :y, :name => :to_s, :age => :to_i > > > > That is, :x and :y receive the normal attr_accessor treatment, while > > > > :name and :age get casting as well. > > I think adding this functionality to attr_accessor is ok, but I would go ahead and alias attr_accessor_with_cast as well. > hmm..just occured to me, how will the code handle it if there are only hash > arguments? in other words i'm not so sure what the methods args should be. > suggestion? def f(*a) p a end f(5,6,1=>2) #=> [5, 6, {1=>2}] f(5,6,1=>2,3=>4) #=> [5, 6, {1=>2, 3=>4}] f(1=>2,3=>4,5,6) #=> SyntaxError: compile error -- Jim Freeze ---------- Better dead than mellow.