Linked Questions

14 votes
5 answers
37k views

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(...
sunny1304's user avatar
  • 1,694
16 votes
3 answers
13k views

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 ...
Cu1ture's user avatar
  • 1,283
3 votes
3 answers
994 views

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 ? ...
OneMoreError's user avatar
  • 7,748
4 votes
4 answers
880 views

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 ...
markthethomas's user avatar
289 votes
9 answers
122k views

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 ...
LuxuryMode's user avatar
  • 33.8k
17 votes
5 answers
6k views

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 ...
LuckyLuke's user avatar
  • 49.2k
5 votes
4 answers
4k views

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 ...
Sameer Anand's user avatar
2 votes
3 answers
1k views

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, ...
suresh's user avatar
  • 137
3 votes
3 answers
533 views

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 ...
Lennie's user avatar
  • 10.9k
4 votes
2 answers
2k views

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'...
Robert's user avatar
  • 311
2 votes
4 answers
499 views

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 ';' ...
Deon Heunis's user avatar
0 votes
3 answers
406 views

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 ...
boulder_ruby's user avatar
0 votes
1 answer
427 views

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, ...
Richlewis's user avatar
  • 15.4k
4 votes
1 answer
229 views

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" ...
Kvass's user avatar
  • 8,494
0 votes
2 answers
138 views

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"?
user705414's user avatar
  • 21.3k

15 30 50 per page