Ruby – :Symbols and “Strings”

I’m no ruby expert.
Actually i only know enough to write a bit of chef recipes.
If you read enough chef recipes you’ll notice a syntax like the following occur often

default[:mario][:powerup] = "mushroom"

and sometimes you’ll see it as

default["luigi"]["powerup"] = "fireflower"

So what’s the difference?


A symbol is immutable. This means you’re not reassigning values to it later. It stays as is, like a hillbilly in a trailer home.


A string is mutable. This means you can keep changing the value of it on the fly. Like a gigolo in a bad economy.

All of this information was stolen from another extremely useful and thorough blog at:
He’s exponentially better at explaining this than i am.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s