Arc Forumnew | comments | leaders | submitlogin
1 point by Pauan 4692 days ago | link | parent

Just added in optional and rest args for functions:

  (fn (a b (o c 5))
    (list a b c))

  (function (a, b, c) {
      c = c || 5;
      return [a, b, c];
  })


  (fn args args)

  (function () {
      var args = Array.prototype.slice.call(arguments);
      return args;
  })


  (fn (a b . c)
    (list a b c))

  (function (a, b) {
      var c = Array.prototype.slice.call(arguments, 2);
      return [a, b, c];
  })
I think that's enough for one day. I'm not sure if a simple boolean test is enough for optional args. Perhaps they should test explicitly against undefined?