From: Phrogz Date: 2007-02-15T00:15:08+09:00 Subject: Re: Initializing dynamic instance methods On Feb 14, 7:31 am, "Lars Olsson" wrote: > Hi list! > > What's the best way to remedy the error/warning that the following > code produces? > > class Parent > def self.foo() > module_eval("def foo(); @foo; end") > module_eval("def foo=(newfoo); @foo = newfoo; end") > end > end I dunno what your criteria is for 'best', but this fixes it: module_eval("def foo(); @foo ||= nil; end") (Though that runs over values of false with nil.)