0

What's the significance of calling void before returning in ramda's arity function?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
c24w
  • 7,421
  • 7
  • 39
  • 47
  • Perhaps it actually removes the last argument? I do notice that it takes a parameter `n` that would not be desired to pass to the closure when passing `arguments`. – Demonslay335 Nov 05 '14 at 12:09

2 Answers2

1

To just make sure no weird errors/warnings are popping up, as far as I know. If by any change the variable is made elsewhere with values. void makes it empty.

  • Void doesn't alter the value of a variable, it just "[evaluates the given _expression_ and then returns `undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void)". For example `(function (a) { void a; return a; })(123);` returns `123`, not `undefined`. – c24w Nov 07 '14 at 09:45
1

ramda co-author here. That is an artifact of some of the code linting we do. We want to be warned if there are ununsed parameters in a function definition. In the case of arity, the params are only there to create a function with the correct, well, arity. Adding the void arg_n passes the linter.

  • Thanks for the answer. I assumed it would be for something like linting after someone mentioned warnings in a comment (which was then deleted). – c24w Nov 15 '14 at 10:56