Ruby Language Changing a method with parameters


Example

You can access the exact same context as the method you override.

class Boat
  def initialize(name)
    @name = name
  end

  def name
    @name
  end
end

puts Boat.new("Doat").name # => "Doat"

class Boat
  def name
    "⛵ #{@name} ⛵"
  end
end

puts Boat.new("Moat").name # => "⛵ Moat ⛵"