From: Jason Lillywhite Date: 2009-03-18T13:40:14+09:00 Subject: local state variables unique to different objects Is there a way to get local state variables to be unique for different objects? See my example bank account: class Acc @@balance = 100 def withdraw( amount ) if @@balance >= amount @@balance = @@balance - amount else "Insufficient Funds" end end @@balance end irb(main):012:0> check1 = Acc.new => # irb(main):013:0> check1.withdraw 50 => 50 irb(main):014:0> check1.withdraw 40 => 10 irb(main):015:0> check1.withdraw 25 => "Insufficient Funds" This is great - but if I create a new object 'check2' it doesn't start with a new balance of 100. What am I doing wrong here? irb(main):016:0> check2 = Acc.new => # irb(main):017:0> check2.withdraw 40 => "Insufficient Funds" I wanted this to return 60 -- Posted via http://www.ruby-forum.com/.