# Ruby Symbol

**URL:** <https://www.ruby-forum.com/t/ruby-symbol/83138>\
**Category:** Ruby\
**Created:** [January 23, 2007, 9:03pm UTC](https://www.ruby-forum.com/t/ruby-symbol/83138 "2007-01-23T21:03:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliasxneo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/df705f/32.png) [@aliasxneo](https://www.ruby-forum.com/u/aliasxneo)\
**Post date:** [January 23, 2007, 9:03pm UTC](https://www.ruby-forum.com/t/ruby-symbol/83138/1 "2007-01-23T21:03:19Z")

</div>

I have been looking into what exactly a Ruby symbol is and have gotten  
some decent info on how they work. I have only one question, how are  
they used in functions like in Rails? I see Rails function like:

func(“string”, :symbol =\> “string”)

How is the combination of the symbol and the string being used inside  
the function? Is this some kind of convention?

I don’t want to start another war on what symbols are for, I just want a  
little clarification on how they are used in the context I provided  
above. Thanks.

- Josh

---

<div class="post-metadata">

**Author:** ![aliasxneo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/df705f/32.png) [@aliasxneo](https://www.ruby-forum.com/u/aliasxneo)\
**Post date:** [January 23, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/ruby-symbol/83138/2 "2007-01-23T21:18:14Z")

</div>

On Wed, 2007-01-24 at 05:03 +0900, AliasX Neo wrote:

> I have been looking into what exactly a Ruby symbol is and have gotten  
> some decent info on how they work. I have only one question, how are  
> they used in functions like in Rails? I see Rails function like:
> 
> func(“string”, :symbol =\> “string”)

> How is the combination of the symbol and the string being used inside  
> the function? Is this some kind of convention?
> 
> I don’t want to start another war on what symbols are for, I just want a  
> little clarification on how they are used in the context I provided  
> above. Thanks.

AFAIK you are passing a string and a Hash as an argument to the above  
method.  
So implementation would look like:

def func(text,option\_hash)

# text contains the string

# option\_hash is the hash as usual.

p option\_hash[:symbol] #=\> “string”  
end

Using symbols as Hash keys is convention for sure.
