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 trialfilip faber
3,078 PointsWhen we declare key and value in the hash, what's the difference between putting strings on key and key without strings?
Hi,
when we declare new hash and set keys and values. What's the difference if we set strings on keys and setting them without strings: example hash={"key" => "key", "value" => "value"} or without (" ") hash={key => "key", value => "value"}
1 Answer
Tyler Maxwell
Courses Plus Student 42,021 PointsHey Filip, in Ruby, a hash can be created using either of the following: ``` hash = { key: value} or hash = { "key" => value}
You can't use a bare word (a word without quotation marks) as a key. I has to be a "string" or a :symbol. I hope that helps.
filip faber
3,078 Pointsfilip faber
3,078 Pointsthank you :)