Example 1 — Official Second and Last
Pick the second argument, then the last one — the samples from the Ramda docs.
console.log(R.nthArg(1)('a', 'b', 'c')); // "b"
console.log(R.nthArg(-1)('a', 'b', 'c')); // "c" How It Works
- Build a picker.
R.nthArg(1)returns a function that reads slot1. - Call it. Slots are
'a'= 0,'b'= 1,'c'= 2, so you get'b'. - Count from the end.
-1becomes3 + (-1) = 2→'c'. - Same idea as
at(). Negative positions work likeArray.at(-1), but on arguments.
