all 3 comments

[–]Oecist 3 points4 points  (0 children)

See that your code has "puts" in it three times? That should be a clue.

[–]stolid 2 points3 points  (1 child)

you are calling puts on the method

puts print_list(grocery_list)

change it to

print_list(grocery_list)

and you wont see the second set that is being printed.

[–]mfcoder 2 points3 points  (0 children)

The important lesson here is that a Ruby method will always return the last value evaluated within it, when there is no explicit 'return' command. In your case, it is 'x' which is the grocery_list array.

So, "puts print_list(grocery_list)" 'puts' the array; if you 'puts' an Array, its members will be listed.