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 Foundations Ruby Core Symbols

Roy Huang
Roy Huang
4,367 Points

confused with symbol and regular keys

Hello everyone,

I just finish the video and create the same program in the video.

I don't quite understand what does symbol do, and in fact, when I replace the symbol with regular keys, it still works. It makes me even more confused.

Thank you!

ps. and could someone tell me how to copy and paste my code and post it on this forum with good structure and color?Thanks!

1 Answer

Long story short. Symbols are immutable and have better namespacing, also they're faster as they cache on your computer.

See this by opening your ruby console in terminal $ irb and type puts Symbol.all_symbols.inspect

You see? How cool. lol.

Also, check this link for more info.

Roy Huang
Roy Huang
4,367 Points

Hello Jarad, thank you for the link!

I will go through it and see if I could get it