Based on your two methods there, I’d say that the person writing means
Class#method
to be an instance method, while
Class.method
is a class method. However, I’m not sure that it’s used that way in
general.
Around here, from what I’ve gathered, # is simply a prefix that means
"the following word is a method." So if I’m talking about the foo
method, I’d say #foo. That way you know it’s a method. It’d be sort
of like writing foo() when talking about C.
It’s a way of distinguishing between an instance method and a class
method in the documentation. When we say IO#each_byte, we’re referring
to an instance method of class IO, whereas IO.foreach is a class
method.
I personally don’t like to convention too much, but I’m not sure I can
think of a better one.
Cheers
Dave
···
On Feb 2, 2004, at 8:19, Brad wrote:
All:
This may be mentioned somewhere, but I have yet to see an explanation
of what the difference between:
Based on your two methods there, I’d say that the person writing means
Class#method
to be an instance method, while
Class.method
is a class method. However, I’m not sure that it’s used that way in
general.
Around here, from what I’ve gathered, # is simply a prefix that means
“the following word is a method.” So if I’m talking about the foo
method, I’d say #foo. That way you know it’s a method. It’d be sort
of like writing foo() when talking about C.
Dan
Dan:
Thanks for the response! Now that I know, everytime I look something
up in the ProgrammingRuby.chm I won’t get that nagging feeling.
This may be mentioned somewhere, but I have yet to see an explanation
of what the difference between:
Class#method
and
Class.method
is in the documentation.
Class#instance_method (Array#size)
Class.class_method (Regexp.escape)
Class methods are really just singleton methods on a class object.
That’s why I prefer Class.method notation to Class::method, which is
also allowed.
Class#method is a documentation convention only; the language does not
recognise it.
Cheers,
Gavin
Gavin:
Hey thanks for the reply! I kind of figured that the use of ‘#’ between
a class and a method was only a documentation convention. But it wasn’t
clear what the notation was used to mean. i.e. both # and . were used,
but without explanation of the difference.
It’s been mentioned that the use of # signifies an instance method and
the use of . signifies a class method. (Thanks to Dan Doel for this
explanation) Though, as Dan said, it’s unclear if this is the actual
difference between the two symbols.
Thanks,
Brad
···
On Tuesday, February 3, 2004, 1:19:57 AM, Brad wrote:
This may be mentioned somewhere, but I have yet to see an explanation
of what the difference between:
Class#method
and
Class.method
is in the documentation.
It’s a way of distinguishing between an instance method and a class
method in the documentation. When we say IO#each_byte, we’re referring
to an instance method of class IO, whereas IO.foreach is a class
method.
I personally don’t like to convention too much, but I’m not sure I can
think of a better one.
I’ve seen Smalltalkers use this:
MyClass >> instanceMethod
MyClass class >> classMethod
Jim
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“An operating system is a collection of things that don’t fit into a
language. There shouldn’t be one.”
– Dan Ingalls
Throughout this book, we use the following typographic notations.
. . .
Within the text, Fred#doIt is a reference to an instance method (doIt)
of class Fred, while Fred.new is a class method, and Fred::EOF is a
class constant
Cheers
Dave
···
On Feb 2, 2004, at 8:59, Brad wrote:
Hey thanks for the reply! I kind of figured that the use of ‘#’
between
a class and a method was only a documentation convention. But it
wasn’t
clear what the notation was used to mean. i.e. both # and . were used,
but without explanation of the difference.
Hey thanks for the reply! I kind of figured that the use of ‘#’
between
a class and a method was only a documentation convention. But it
wasn’t
clear what the notation was used to mean. i.e. both # and . were used,
but without explanation of the difference.
From the preface:
Notation Conventions
Throughout this book, we use the following typographic notations.
. .
Within the text, Fred#doIt is a reference to an instance method (doIt)
of class Fred, while Fred.new is a class method, and Fred::EOF is a
class constant
Cheers
Dave
Dave:
Thank you for your response, it’s appreciated.
I didn’t see that text before, honest. Thank you for pointing it out
and I’m sorry for wasting everyone’s time with such a silly question.