Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "class#method" mean in ruby? [duplicate]

Tags:

ruby

Possible Duplicate:
Why are methods in ruby documentation preceded by a pound sign?

EDIT: Duplicate of Why are methods in ruby documentation preceded by a pound sign?

Hi,

I'm trying to learn Ruby for fun at my spare time with the free Programming Ruby book. It is mostly fairly straight forward but I kept seeing notations like this KaraokeSong#to_s, which is not really explained in the earlier chapters of the book.

I know it meant <class>#<method> but it is something you can use in the code? or just a notation ruby programmers use to specifiy a method like <class>::<method> notation used by C++ programmers?

like image 964
oscarkuo Avatar asked Aug 22 '09 20:08

oscarkuo


People also ask

What is the meaning of class?

class. / (klɑːs) / noun. a collection or division of people or things sharing a common characteristic, attribute, quality, or property. a group of persons sharing a similar social position and certain economic, political, and cultural characteristics.

What do you mean by class in school?

1a : a group of students meeting regularly to study the same subject. b : the period during which such a group meets. c : a course of instruction. d : a group of students who graduate together class of 1990.


1 Answers

# = instance method

:: = class method

Per ruby docs:

Use :: for describing class methods, # for describing instance methods, and use . for example code.

like image 116
Andy Gaskell Avatar answered Oct 05 '22 22:10

Andy Gaskell