Say I have the following:
module Foo
def bar
puts “Baz”
end
end
If I want to write about (in some documentation, or a bug report) the
bar method of the Foo module, what’s the best way of referring to it?
E.g.,
I have found a bug in Foo::bar
I have found a bug in Foo.bar
I have found a bug in the bar method of the Foo module
Or some other way?
Many thanks!
Charles
Foo#bar is usually used for instance methods, Foo.bar for class
methods. In this case I think Foo#bar is correct.
Farrel
On 03/02/2010 11:37, Farrel L. wrote:
Foo#bar is usually used for instance methods, Foo.bar for class
methods. In this case I think Foo#bar is correct.
Ah, yes, I think I’ve seen that. And so Foo::Bar would be for a class
within a module?
Many thanks, Farrel.
Charles
On Wed, Feb 3, 2010 at 10:13 AM, Charles R.
[email protected] wrote:
On 03/02/2010 11:37, Farrel L. wrote:
Foo#bar is usually used for instance methods, Foo.bar for class
methods. In this case I think Foo#bar is correct.
Ah, yes, I think I’ve seen that. And so Foo::Bar would be for a class within
a module?
More generally
Foo::Bar
refers to the constant named Bar within the namespace named Foo.
Foo could be either a Module or a Class
The value of Bar could be a Module, a Class, or actually any value
module Foo
class Bar
Baz = 42
end
module ClassMethods
end
end
Foo is a module here,
Foo::Bar is a class
Foo::ClassMethods is a module
Foo:Bar::Baz is an integer.
–
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: Rick DeNatale - Developer - IBM | LinkedIn
On 3 February 2010 18:25, Rick DeNatale [email protected] wrote:
More generally
 Foo::Bar
refers to the constant named Bar within the namespace named Foo.
Rick, many thanks, your explanation is most illuminating.
Cheers,
Charles