Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Jordano Moscoso
3,104 PointsWays to push a Hash
Why when i tried this does not work?:
@transactions.push({"description"=>description,"amount"=>amount})
and this works:
@transactions.push(description:description,amount:amount)
Thanks.
3 Answers

Kin Pi
14,086 PointsThe hash should have the keys description and amount, as symbols, and values that match the arguments to the method.
The instruction said that they have to be symbols.

Eliza SJ
4,587 PointsI wish he'd explained symbols a bit better... I'm a bit confused as to why the hash has to absolutely be created using symbols. What makes this particular case only work with symbols?

piper piperian
8,958 PointsHi Eliza,
i hope I answered your question on the other post, but the symbol here is set as is, b/c of the way he framed the code @transaction.push(description: description, amount: amount)
In ruby, this returns: {:description => "description", :amount => "amount"}
the symbol works like quotes around string around a hash KEY.