Iβm creating function x with 1 param, and I want to create function x with the same name with 2 params, however defining x twice (but with different params) only has the second function defined, else Runtime Error - ArgumentError ... wrong number of arguments (given 1, expected 2)
My concrete usecase is creating a sample fader:
times.times do
sample sample
amp -= ampFade
sleep sleep
end
but I also want to optionally pass in the starting amp and panning options, along with other params as it becomes more complex.
Currently I have to either create a new function whose name contains the additional params, ex. sample_fade_panning
, or I have to call sample_fade
with a bunch of nil
, which is unintuitive because it requires looking up the function definition each time, and potentially passing in an almost full set of nills just to get the basic functionality.
I might be able to implement something by having a 1 param list passed into the function, but Iβm not seeing the ability to pass in key:value pairings, which would allow me to identify the param names.