linkDistance and linkStrength called with no arguments return function, not value #895

Closed
ezyang opened this Issue Nov 14, 2012 · 3 comments

Projects

None yet

3 participants

@ezyang
ezyang commented Nov 14, 2012

As seen in this transcript:

> force.linkDistance
function (x) {
      if (!arguments.length) return linkDistance;
      linkDistance = d3_functor(x);
      return force;
    }
> force.linkDistance()
function () {
      return v;
    }
> force.linkDistance()()
40

This is not consistent with the other methods.

@jasondavies
Member

This is expected because linkDistance and linkStrength can take functions as well as constants. If you specify a constant, it is converted to a function internally.

@mbostock
Member

This is a valid bug, though; the code shouldn't expose the fact that it's converting constants to a function internally. I was just lazy.

@jasondavies
Member

Ha! :)

@mbostock mbostock closed this in d287b63 Feb 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment