Reputation: 23
I have the following code:
person1 = { :first => "bob", :last => "perry"}
person2 = { :first => "fred", :last => "perry"}
person3 = {:first => "jane", :last =>"perry"}
family = {:dad => person1, :son => person2, :mum => person3}
puts (family[:dad][:last],family[:dad][:first])
It prints out:
perry
bob
nil
Why does it also output nil?
Upvotes: 2
Views: 714
Reputation: 160311
Because you're in irb
, which prints out the return value of the last method run, and puts
returns nil.
(Or in rails c
.)
Upvotes: 4