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 Build a Grocery List Program Build a Grocery List Program: Part 2

1,397 Points

No implicit conversion of string into integer


I'm experiencing some problems with my code, can someone please take a look and let me know what's wrong?

The mistake I get 'No implicit conversion of string into integer' seems to refer to the square brackets ["items"] on the last line of the code.

I'm a beginner so I'm not really sure what could cause this problem. I checked the class of the def create_list and it tells me it is a Fixnum (is this normal?) and I'm thinking maybe this is where the issue comes from?


def create_list
  print "What's the name of your grocery list? "
  list_input = gets.chomp

  grocery_list_name = { "name" => list_input, "items" => Array.new } 
  return hash

def add_grocery_item()
  print "What's on your grocery list? "
  item_name = gets.chomp

  print "How much? "
  quantity = gets.chomp.to_i

  hash = { "name" => item_name, "quantity" => quantity }
  return hash

list = create_list()

1 Answer

Clayton Perszyk
Clayton Perszyk
Treehouse Moderator 48,837 Points

In create_list change the return value from hash to grocery_list_name, as that is the hash you are setting.

1,397 Points

Thanks so much, this makes sense!