Say I have a generic Proc, Lambda or method which takes an optional second argument:
pow = -> (base, exp: 2) { base**exp }
Now I want to curry this function, giving it an exp of 3.
cube = pow.curry.call(exp: 3)
There's an ambiguity here, arising from the keyword arguments and the new hash syntax, where Ruby interprets exp: 3 as a hash being passed as the first argument, base. This results in the function immediately being invoked, rendering a NoMethodError when #** is sent to the hash.
Setting a default value for the first argument will similarly result in the function being immediately invoked when currying, and if I mark the first argument as required, without providing a default:
pow = -> (base:, exp: 2) { base**exp }
the interpreter will complain that I'm missing argument base when I attempt to curry the Proc.
How can I curry a function with the second argument?