From: Ruby Student Date: 2013-07-02T21:46:56+09:00 Subject: Re: Why the use of a pound (#) sign with Enumerable --089e01184c3e66393504e086bd2f Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable These are excellent replies. I tried *google* before I tried the forum and it did not come up with anything useful. Hopefully people will be able to find this discussion on *google* later on. Thank you On Mon, Jul 1, 2013 at 5:10 PM, Robert Jackson wro= te: > These sorts of things are somewhat difficult to google for (I tried to > find a nice article to reference, but couldn't find one quickly.), so > hopefully this helps... > > The methods themselves do not have a '#' in front of them. > > The '#' is usually used to indicate an instance method and often '.' is > used to indicate a class/module method. > > So given the following class: > > class FooBar > def self.say_hello > puts 'hello from a class method' > end > > def say_hello > puts 'hello from an instance method' > end > end > > FooBar#say_hello references the instance method. > FooBar.say_hello references the class method. > > Robert Jackson > > -- twitter: rwjblue > -- github: rjackson > > > On Jul 1, 2013, at 4:02 PM, Ruby Student wrote: > > > Team, > > > > Please be easy on me, but I was wondering why methods that belong to th= e > Enumerable class have a # (pound) sign. For instance: > > > > =95 #all? > > =95 #any? > > =95 #chunk > > =95 #collect > > Etc. > > > > What is the meaining of the # there? > > > > Thank you > > > > -- > > Ruby Student > > > --=20 Ruby Student --089e01184c3e66393504e086bd2f Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable
These are excellent replies. I tried google before I tried the forum and it did not come up with anything useful.
Hopefully people will be able to find this discussion on google<= /b> later on.

Thank you


On Mon, Jul 1, 2013 at 5:10 PM, Robert Jackson <r= obert.w.jackson@me.com> wrote:
These sorts of things are somewhat difficult= to google for (I tried to find a nice article to reference, but couldn'= ;t find one quickly.), so hopefully this helps...

The methods themselves do not have a '#' in front of them.

The '#' is usually used to indicate an instance method and often &#= 39;.' is used to indicate a class/module method.

So given the following class:

class FooBar
=A0 def self.say_hello
=A0 =A0 puts 'hello from a class method'
=A0 end

=A0 def say_hello
=A0 =A0 puts 'hello from an instance method'
=A0 end
end

FooBar#say_hello references the instance method.
FooBar.say_hello references the class method.

Robert Jackson

=A0 -- twitter: =A0rwjblue
=A0 -- github: rjackson


On Jul 1, 2013, at 4:02 PM, R= uby Student <ruby.student@gmai= l.com> wrote:

> Team,
>
> Please be easy on me, but I was wondering why methods that belong to t= he Enumerable class have a # (pound) sign. For instance:
>
> =A0 =A0 =A0 =95 #all?
> =A0 =A0 =A0 =95 #any?
> =A0 =A0 =A0 =95 #chunk
> =A0 =A0 =A0 =95 #collect
> Etc.
>
> What is the meaining of the # there?
>
> Thank you
>
> --
> Ruby Student





--
Ruby Studen= t
--089e01184c3e66393504e086bd2f--