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

Ruby Ruby Collections Ruby Arrays Adding Items to Arrays

after answering task one, it won't let me submit task two because task one is no longer valid.

I was told that when I submitted task one it was correct, but when I submit task two, it says that task one is no longer valid, and I am not sure why.

array.rb
grocery_list = ["milk", "eggs", "bread"]
grocery_list.push "carrots"
grocery_list.unshift = "celery"

I see that my syntax was off when I was trying to push the new array item. Thanks for your help in responding!

Hey, no problem! :-)

2 Answers

Kevin Korte
Kevin Korte
28,149 Points

Try using the unshift method without the equals, just like you did with the push method

That's not too clear but it is because you got the last line slightly wrong.

If you amend that to:

grocery_list.unshift("celery")

then that should work fine.

Steve.