marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.01k stars 795 forks source link

Ch. 6 – Argument differences in matrix classes #376

Closed mikegowen closed 6 years ago

mikegowen commented 6 years ago

In the Matrix class constructor, you set the default for the content parameter like this:

constructor(width, height, content = () => undefined) (i.e. no parameters in the function)

But then in theSymmetricMatrix class constructor, set the default for the content parameter like this:

constructor(size, content = (x, y) => undefined) (i.e. x and y parameters in the function)

Is there a reason these are different?

marijnh commented 6 years ago

Is there a reason these are different?

No, they'll behave the same. But I guess having the arguments in there is helpful for showing people how the function will be used. Attached patch adds them to the first example.