Fixing Bad Code the Wrong Way

Difficulty:
Easy

Tags:
method_missing, classes

Instructions:
Your coworker did a bad job defining a class. Fix it for him using #method_missing.

Code:
class Person
  def initialize(name, age, incoming_race)
    @name = name
    @age = age
    self.race = incoming_race
  end

  def nam
    @name.split.map(&:capitalize).join(" ")
  end

  def agE
    @age
  end

  def method_missing(m, *args)
    ___
    else
      super
    end
  end
end

person = Person.new("kurt vonnegut", 89, "caucasian")

assert_equal person.name, "Kurt Vonnegut"
assert_equal person.race, "Caucasian"
assert_equal person.age, 89

Your Solution

Ruby 1.9.3

Back to Problems