A
ara.t.howard
I would write it:
def foo
return @foo if @foo
@foo = Foo.new
@foo.bar = 'bar'
@foo
end
$ wc
...
6 14 77
Ten characters and one line more typing, but less punctuation. (And those
ten extra characters will be mostly be handled by my tab key.)
and quite easy to golf if line count matters that much
def foo
@foo ||= Foo.new.instance_eval{ self.bar = 'bar'; self }
end
-a