I'm doing the following Ruby Tutorial http://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/48-advanced-modules/lessons/118-wrapping-up-modules
One of the exercises asks me to
...define a static method square in the module Math. It should obviously return the square of the number passed to it...
Why does it only work when I prefix the method definition with "self"? E.g. the following works:
module Math
def self.square(x)
x ** 2
end
end
But the following does NOT work:
module Math
def square(x)
x ** 2
end
end
Why is this? For reference, the method is being called like puts Math.square(6)