Changing a method with parameters

suggest change

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 ⛵"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents