...

Symbols as function names?

Keleth
05-22-2012, 03:39 PM
I think the biggest road block I have with ruby right now is symbols. I'm not quite grasping their use.

So far as I understand it, its an efficiency system of using the same short string multiple times, as an identifier (such as for a hash key). However, I'm not seeing their use/purpose beyond that.

Further more, one of the guides I'm currently following (Learning Ruby the Hard Way), defines a function, then uses a symbol of the function name to reference it. Are function names automatically defined as symbols? As a function name has to be unique, why use a symbol to represent it? Is this acting more like a pointer?

kaizenfury7
06-01-2012, 09:16 AM
What's the example from Learning Ruby the Hard Way that you're referring to?

I use symbols purely for efficiency. I'm guessing the example is passing some method a method name as a string, and is looking up the method to call it. Hopefully I can tell you more after seeing the example.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum