Reputation: 48916
I have the following hash:
my_info = {'first_name' => 'xyz', 'last_name' => 'mnl', 'age' => 27}
When I try to delete the age
key as follows:
my_info.delete['age']
I get the following:
r.rb:5:in `delete': wrong number of arguments (0 for 1) (ArgumentError)
from r.rb:5
Why is that?
Thanks.
Upvotes: 6
Views: 3869
Reputation: 21180
The reason for that is because delete
is a method so you must use parenthesis instead like this:
my_info.delete('age')
Upvotes: 21