Public
Authored by Fernando Basso

Ruby - Methods

Edited

In Ruby, a class like Foo is itself an object, an instance of the Class class.

By doing

class Thing
  def self.foo
    'hey'
  end
end

we are defining a method on the Thing object, not on instances of Thing.

methods.rb 400 Bytes
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment