From: Robert Klemme Date: 2006-07-07T21:46:00+09:00 Subject: Re: quick metaprogramming question: collecting arguments across calls 2006/7/7, William Morgan : > Hi all, > > Quick question: is there a better way to write Foo.contains below? > Forcing the lexical scoping like this feels wrong. > > class Foo > def self.contains *o > @contents ||= [] > @contents += o > contents = @contents > define_method(:contents) { contents } > end > end Any reason why you cannot simply use a normal attribute accessor? class Foo class <