Inheritance

From Reia

Jump to: navigation, search

Simple inheritance

Reia supports simple inheritance. All objects descend from the Object class. Methods from ancestor classes are passed along to their descendants.

To inherit from an existing class, use the < operator:

class Descendant < Ancestor
  def newmethod1
    ...
  end
  
  def newmethod2
    ...
  end
end

The super keyword

Sorry, super is presently unimplemented

Methods redefined in a subclass can still call the original superclass method using the super keyword:

class Foo
  def something
    42
  end
end

class Bar < Foo
  def something(n)
    super() + n
  end
end

class Baz < Bar
  def something(n)
    super(n) * n
  end
end
Personal tools