Laughing_Man
Laughing_Man

Reputation: 179

Undefined method Ruby

I would like to create an array of my custom objects. But when I try to call a method of the one of the objects, I get an error undefined method `get_id' for #Map:0x000055cf036a0838>.

Here is my code:

maps = []
map = Map.new(id)
maps.push(map)
puts maps[0].get_id

Upvotes: 1

Views: 773

Answers (1)

mrzasa
mrzasa

Reputation: 23307

It seems that your Map class doesn't define get_id method. Hint - in Ruby you don't use get_ and set_ prefixes, so maybe you just wanted to call maps[0].id?

Upvotes: 3

Related Questions