I have the following code:
class Person
attr_reader :name, :balance
def initialize(name, balance=0)
@name = name
@balance = balance
puts "Hi, #{name}. You have $#{balance}!"
end
end
class Bank
attr_reader :bank_name
def initialize(bank_name)
@bank_name = bank_name
puts "#{bank_name} bank was just created."
end
def open_account(name)
puts "#{name}, thanks for opening an account at #{bank_name}!"
end
end
chase = Bank.new("JP Morgan Chase")
wells_fargo = Bank.new("Wells Fargo")
me = Person.new("Shehzan", 500)
friend1 = Person.new("John", 1000)
chase.open_account(me)
chase.open_account(friend1)
wells_fargo.open_account(me)
wells_fargo.open_account(friend1)
When I call chase.open_account(me) I get the result Person:0x000001030854e0, thanks for opening an account at JP Morgan Chase!. I seem to be getting the unique_id (?) and not the name I assigned to @name when I created me = Person.new("Shehzan", 500),. I've read a lot about class / instance variables and just can't seem to figure it out.