I am not sure why this method is not running.
The compile error reads:
sequence5.rb:1:in `sequence5': wrong number of arguments (2 for 1) (ArgumentError) from sequence5.rb:11:in `<main>'
But as you can see clearly, sequence5 method should take 2 arguments, one for args hash and the other for b proc.
The code I’m trying to run is here.
def sequence5(args, &b)
n, m, c = args[:n], args[:m], args[:c]
i = 0
while i < n
b.call(i*m+c)
i += 1
end
end
p = Proc.new {|x| puts x}
sequence5({:n=>3, :m=>4, :c=>0}, p)
p is not an argument, it’s a block and Ruby has different syntax for passing a block