Linked Questions
17 questions linked to/from How to understand symbols in Ruby
14
votes
5
answers
37k
views
Understanding Ruby symbol as method call [duplicate]
class A
def test
"Test from instance"
end
class << self
def test
"Test from class"
end
end
end
p A.send(:test) # "Test from class"
p A.new.method(...
16
votes
3
answers
13k
views
What is the difference between a symbol and a variable in Ruby? [duplicate]
I am trying to understand what the difference is between a symbol and a variable in ruby. They seemed to do the exact same thing in giving a name that references an object.
I have read that symbols ...
3
votes
3
answers
994
views
Significance of colon : in Ruby [duplicate]
Possible Duplicate:
Understanding Symbols In Ruby
What is the colon operator in Ruby?
I really feel naive asking this, but I'm going to go ahead and ask :
What is the importance of : in ruby ?
...
4
votes
4
answers
880
views
When to use symbols in Ruby [duplicate]
I'm not clear on the value and proper use of symbols.
The benefit seems to be that they remove the need for multiple copies of the same hash by letting it exist only in memory. I wonder whether this ...
289
votes
9
answers
122k
views
What is the colon operator in Ruby?
When I say { :bla => 1, :bloop => 2 }, what exactly does the : do? I read somewhere about how it's similar to a string, but somehow a symbol.
I'm not super-clear on the concept, could someone ...
17
votes
5
answers
6k
views
Using Ruby Symbols
First time I tried learning Ruby was 2 years ago, now I have started again. The reason I stopped was because I could not understand the Symbol class. And now I am at the same point again, completely ...
5
votes
4
answers
4k
views
Understanding Ruby variables and symbols?
I am having some trouble understanding the syntax of variables and symbols in Ruby. I am reading a book called Agile Web Development with Rails 4. I am trying to learn both Ruby and Rails so that I ...
2
votes
3
answers
1k
views
What is the use of symbols?
I heard that two symbols with the same name create only one memory area, but two strings with the same content create two memory areas.
What is the use of symbols?
Is symbol like a variable? If so, ...
3
votes
3
answers
533
views
How do Ruby symbols work?
I read that Ruby has a language featured called "labels", how does that work?
Update:
I saw it at http://ruby.about.com/od/gems/qt/shorturl.htm where the author talks about a label at the bottom of ...
4
votes
2
answers
2k
views
When are symbols used in Rails?
I assume alot of these are built in or convetions, but methods like belongs_to or require uses a symbol for the model name it takes as an argument.
And when it comes to methods like before_action, I'...
2
votes
4
answers
499
views
Ruby on Rails - Ruby Operator Precedence - Parentheses
The following code results in an error
Example 1
if params[:id] == '2' || params.has_key? :id
abort('params id = 2 or nothing')
end
syntax error, unexpected tSYMBEG, expecting keyword_then or ';' ...
0
votes
3
answers
406
views
Is a variable the quintessential "pointer"? Is params[] a pointer? Is params[] a variable?
Please, do not attack. Here's the example and code that made me think about this.
I'm studying ruby on rails and am in the midst of the MVC and params[] operator. And have been laying down some ...
0
votes
1
answer
427
views
passing params through a link_to rails 3
Im just looking for some clarification on the following piece of code, well part of it.To give some background i have an app where you can upload recipes, search recipes and save them as favourites, ...
4
votes
1
answer
229
views
Ruby -- understanding symbols
I'm having a little trouble understanding how symbols work in my code. I understand that they are essentially immutable strings, but I don't fully understand how symbols automatically "recognize" ...
0
votes
2
answers
138
views
Can we just take symbol literal as a "interned string"
Anyone knows if there is similar concept in other popular language compared to symbol literal in Ruby? Can I considered it just as an "Interned String"?