J
Jason Vogel
Source:
[a.rb]
class A
attr_accessor :id
attr_accessor :name
def initialize(id = nil, name = nil)
@id = id
@name = name
end
end
[test.rb]
require 'a'
a1 = A.newname => "test")
a2 = A.newname => "test2")
p a1
p a2
Results:
#<A:0x28c2d80 @id={:name=>"test"}, @name=nil>
#<A:0x28c2678 @id={:name=>"test2"}, @name=nil>
I expected:
#<A:0x28c2d80 @id=nil, @name="test">
#<A:0x28c2678 @id=nil, @name="test2">
So what nuby mistake am I making?
Thanks,
Jason
[a.rb]
class A
attr_accessor :id
attr_accessor :name
def initialize(id = nil, name = nil)
@id = id
@name = name
end
end
[test.rb]
require 'a'
a1 = A.newname => "test")
a2 = A.newname => "test2")
p a1
p a2
Results:
#<A:0x28c2d80 @id={:name=>"test"}, @name=nil>
#<A:0x28c2678 @id={:name=>"test2"}, @name=nil>
I expected:
#<A:0x28c2d80 @id=nil, @name="test">
#<A:0x28c2678 @id=nil, @name="test2">
So what nuby mistake am I making?
Thanks,
Jason