0

Where are these symbols defined, and what are they used for?

:w2_end
:w2_beg
:w1_beg
:w1_end

I found those in my IRB by using the line Symbol.all_symbols .

My Ruby version and IRB versions are:

C:\>ruby -v
ruby 1.9.3p374 (2013-01-15) [i386-mingw32]

C:\>irb --version
irb 0.9.6(09/06/30)

I tried the same in another Ruby and IRB version as below:

C:\>irb --version
irb 0.9.6(09/06/30)

C:\>ruby -v
ruby 1.9.3p392 (2013-02-22) [i386-mingw32]

Arr = Symbol.all_symbols 
Arr.include?(:w2_end) #=> true
Arr.include?(:w2_beg) #=> true
Arr.include?(:w1_beg) #=> true
Arr.include?(:w1_end) #=> true
ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
  • Can you clarify your question? What exactly do you want to know? A symbol is just a symbol. It doesn't mean anything, it doesn't do anything. Your question is like asking what the use of the number `3` is in Ruby. – Jörg W Mittag Mar 08 '13 at 17:12
  • So you did `Symbol.all_symbols`, found those four symbols, and now you want to know what code uses them and what it uses them for? – mu is too short Mar 08 '13 at 17:16
  • @muistooshort yes.you are right. May i have some help on their use? – Arup Rakshit Mar 08 '13 at 18:02
  • @JörgWMittag I got those from the IRB using the above mentioned code. But `symbols` can be variables or methods as well. It is there present means anyway they have some uses. But didn't found any documentation on those. Thus asked here if anyone ever used those, just to let me know then those symbols actual uses. – Arup Rakshit Mar 08 '13 at 18:05
  • But why does it matter? Maybe something somewhere is using the value `6` or a variable called `pancakes`, why do you care? – mu is too short Mar 08 '13 at 18:40
  • @muistooshort I asked this out of my curiosity, hoping that someone might themselves introduced. It is in Ruby means must have some use,otherwise they wouldn't present there,right? – Arup Rakshit Mar 08 '13 at 18:44
  • What's in your .irbrc? Also, what happens when you try this using a ruby you installed with rvm? – Wayne Conrad Mar 08 '13 at 18:52
  • I didn't install my ruby using `rvm`. I am on `windows-7` machine. – Arup Rakshit Mar 08 '13 at 18:57

1 Answers1

1

These symbols don't appear in the Ruby source, nor are they defined when I look for them:

$ rvm 1.9.3-p374 do irb
1.9.3p374 :003 > Symbol.all_symbols.map(&:to_s).grep(/^w\d/)
 => [] 

Have you got your irb configured to load any extensions? Look in your .irbrc, if you have one.

Those symbols are commonly found in, among other places, readline libraries. irb uses readline. Perhaps there's something special about readline on Windows (it being coded in Ruby, for example) that causes those symbols to be defined.

Wayne Conrad
  • 103,207
  • 26
  • 155
  • 191