Http://ruby-doc.org/docs/keywords/1.9/ : (Object)

What is the purpose of
(Object)
next to every keyword in http://ruby-doc.org/docs/keywords/1.9/
?

Trivia question: What is the only keyword with a question mark?

Object is their class, and the root object in Ruby. (Well,
technically BasicObject is now the root object. But that’s if you
want to bypass the rest of the object heirarchy.) As shown in the
core docs, similar notation is standard for all methods.

http://ruby-doc.org/core-1.9.3/Object.html
http://ruby-doc.org/core-1.9.3/BasicObject.html
http://ruby-doc.org/core-1.9.3/

On Tue, Mar 6, 2012 at 3:50 PM, Ralph S. [email protected] wrote:

What is the purpose of
(Object)
next to every keyword in http://ruby-doc.org/docs/keywords/1.9/
?

Trivia question: What is the only keyword with a question mark?

On Tue, Mar 6, 2012 at 8:18 PM, Carina C. Zona [email protected] wrote:

Object is their class, and the root object in Ruby. (Well,
technically BasicObject is now the root object. But that’s if you
want to bypass the rest of the object heirarchy.) As shown in the
core docs, similar notation is standard for all methods.

http://ruby-doc.org/core-1.9.3/Object.html
http://ruby-doc.org/core-1.9.3/BasicObject.html
http://ruby-doc.org/core-1.9.3/

However, the ones Ralph asked about are NOT methods on Object, or any
other class – they are Ruby keywords. There’s an explanation of that
at http://ruby-doc.org/docs/keywords/1.9/keywords_rb.html. Apparently
the keywords were just shoehorned into RDoc, which isn’t really cut
out for describing keywords (just yet).

defined?

On Tue, Mar 6, 2012 at 7:18 PM, Carina C. Zona [email protected] wrote:

Object is their class, and the root object in Ruby. (Well,
technically BasicObject is now the root object. But that’s if you
want to bypass the rest of the object heirarchy.) As shown in the
core docs, similar notation is standard for all methods.

Hmm, I was under the impression that keywords were distinct from
methods. After all, I can’t explicitly specify a receiver when using a
keyword:

$ irb
1.9.2-p290 :001 > self.begin
NoMethodError: undefined method begin' for main:Object from (irb):1 from /Users/kendall/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in
1.9.2-p290 :002 > self.def hi
NameError: undefined local variable or method hi' for main:Object from (irb):2 from /Users/kendall/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in

As such, I’m also confused why a keyword is somehow affiliated with
a class. I’d guess/assume it’s just how the RDoc engine works and was
used to document keywords (???) as opposed to it actually indicating
that keywords are somehow implemented as methods on Object. I’d love
to know, semantically speaking as well as technically, what the case
is here.

On Tue, Mar 6, 2012 at 6:34 PM, Kendall G. [email protected]
wrote:

As such, I’m also confused why a keyword is somehow affiliated with
a class. I’d guess/assume it’s just how the RDoc engine works and was
used to document keywords (???) as opposed to it actually indicating
that keywords are somehow implemented as methods on Object. I’d love
to know, semantically speaking as well as technically, what the case
is here.


Kendall G.
[email protected]

More info here. http://stackoverflow.com/a/9446185/893498 Short
version: keywords are an exception to “everything is an object in
Ruby”. Interesting.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs