mardi 16 août 2016

ruby call optional parameter

I have the following method:

def method(a=1, b=2, c=3, d=4)
  puts a
  puts b
  puts c
  puts d
end

Is there a way to output like this without checking the variables nullity? When I call the method like:

method(5,7)
=> 5
=> 2
=> 7
=> 4

Aucun commentaire:

Enregistrer un commentaire