sawa
sawa

Reputation: 168269

Using `#` in definition

I realized it is possible to have # in a definition:

def Foo#bar
   "blah blah"
end

But I am not sure what it means. I expected an instance method bar defined on class Foo, but that does not seem to be the case. What does it mean?

Upvotes: 1

Views: 76

Answers (1)

jtbandes
jtbandes

Reputation: 118781

# begins a comment in ruby. You are simply defining a method called Foo.

(Note that Foo#bar is commonly used to denote "the instance method bar of class Foo", but it is not a feature of Ruby syntax!)

Upvotes: 4

Related Questions