I was looking at the Ruby documentation, and am wondering if everything is an object then ‘keywords’ are objects as well, correct? And if so, where are they defined in ruby?
The following page totally confused me caused it showed the object with all the keywords in it, however this is not the official Object that is used by all classes, is this mixed-in somehow from a different class??
http://ruby-doc.org/docs/keywords/1.9/Object.html
I guess there are lots of questions above, the main one is: how do ruby keywords get into ruby?
The keywords are not objects but defined in the parser which can be found in
parse.yin the Ruby source. Here’s the relevant part from that file:If you want to know more about the Ruby parser, look at the presentation Hacking parse.y from RubyConf 2009 or Parse.y famtour from Ruby Kaigi 2011.
Also, a lot of the methods that are available everywhere (like e.g.
puts) are defined in the Kernel module.EDIT: There’s also a list of key words in the documentation, thanks @antinome for pointing that out.