Most the time in Ruby parentheses are optional for parameters in method calls. Here is one case where you can expect the unexpected.

class Course
  def track
    puts 'masters'
  end
end

class Elective < Course
  def track(type)
    super
    puts type
  end
end

Elective.new.track('art') 
#=> ArgumentError: wrong number of arguments (1 for 0)

But…

class Course
  def track
    puts 'masters'
  end
end

class Elective < Course
  def track(type)
    super()
    puts type
  end
end

Elective.new.track('art') 
#=> masters

🙂

Leave a Reply

Screen Shot 2013-12-08 at 9.49.35 PM

I have helped a dozen companies build and optimize their engineering teams to deliver great products.

Let’s work together and I can align your business needs with your technology initiatives.