0

Hi guys I am doing this codewar challenge.

The goal is to implement data structure manipulation for method prefill(n, v).

def prefill(n, v)
    some code
end

One of the requirements is to give a default "undefined" value for the method argument v if it's not given when method is called.

I am not sure how I can catch this ArgumentError and re-trigger the iteration of prefill. Can someone help?

Eric Chuhao Chan
  • 367
  • 1
  • 3
  • 5

1 Answers1

3

You don't need to, you need to use default arguments, like this:

def prefill(n, v = nil)
  # code
end
Marek Lipka
  • 50,622
  • 7
  • 87
  • 91