Ruby Tip8: No Method Overloading Supported in Ruby

Neelkanth Ram

13 sec read

As per design, Method overloading is not supported in Ruby.
If you try the below example, you will get “`foobar’: wrong number of arguments (1 for 2) (ArgumentError)“.

[source language=”ruby”]
class Hello
def foobar(a)
def foobar(a , b)
a + b
hello =
puts hello.foobar(4)
puts hello.foobar(4,5)
You may want to check the threads 890619, 431459

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *