Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


20,999 Points

Undefined method 'push'

Hi! After adding the require "./phone_number" and running contact.rb, I get an error:

Traceback (most recent call last):
1: from contact.rb:77:in <main>' contact.rb:15:inadd_phone_number': undefined method `push' for #<PhoneNumber:0x000055f84431c2b0> (NoMethodError)

What am I missing?


Dillon Wyatt
Dillon Wyatt
5,990 Points

Could you show more of the code? I am unfamiliar with the exercise you are working on off hand and there is no automatic link to it.

I wonder if you are trying to .push on an Object and not and Array.

Object << data != Array << data. You would need something more like Object.array << data.

1 Answer

Shaneil Clarke
Shaneil Clarke
4,630 Points

Looks like you're trying to use push method on an object that isn't an Array maybe? Hard to say without example code.