What is the purpose of
(Object)
next to every keyword in RDoc Documentation
?
Trivia question: What is the only keyword with a question mark?
What is the purpose of
(Object)
next to every keyword in RDoc Documentation
?
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.
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 RDoc Documentation
?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.Class: Object (Ruby 1.9.3)
Class: BasicObject (Ruby 1.9.3)
Index of Files, Classes & Methods in Ruby 1.9.3 (Ruby 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 File: keywords.rb [RDoc Documentation]. 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. Where are keywords defined in Ruby? - Stack Overflow 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.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs