[Nitro] Concerns over Og mandating the form of initialize
James Britt
james_b at neurogami.com
Wed Apr 13 17:04:59 EDT 2005
George Moschovitis wrote:
>>f = Foo.allocate
>>p f.create_date # nil
>
>
> og_read restores f.create_data so it is NOT nil.
Yes, currently, because og_read calls new. But using allocate in place
of new will bypass the initialization of @tstamp
Example:
class Foo
attr_accessor :x, :y
def initialize( x=nil, y=nil )
@x = x
@y = y
@tstamp = Time.new
end
def create_date
@tstamp
end
end
f = Foo.allocate
p f.create_date # nil
James
More information about the Nitro-general
mailing list