I’d like to be able to enter a number and specifically request a return from a key named “first”, “second”, or “third” - rather than returning an array of [n1, n2, n3] and then using indexing accordingly.
… and when you do it this way, then the simplest way to select the desired result based on a symbolic key is simply to use the corresponding environment variable:
~first.(10);
So in some ways, the problem as stated is asking for a different way to select something based on a name, when there are already good ways that are more efficient or idiomatic. Sometimes we get stuck on an idea and think “I have to do it this way,” while overlooking simpler ways.
(One might argue that ~first, ~second, ~third are duplicating code. In this specific case, the duplicated code [the argument name] couldn’t be factored out into another function – but if it’s a complex function with some shared operations between the three, then those could be factored out. In the above case, you could also just parameterize: { |number, mul| number * mul }.)