-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toFixed converts x and y coordinates to strings #28
Comments
Although you are correct, I would argue that it makes sense to keep the API consistent with the JavaScript one. I agree that Number#toFixed is kind of annoying, but when I call it I expect a string. |
The problem is that it will break all further functionality of the vector/point, since all other functions are expecting numbers, not strings. If you want to follow Number#toFixed() you should return a new object, since Number#toFixed() does not change the object itself - it returns a new string. var a = 10; a is still a number.. |
Good point. How do you feel about keeping #toFixed as returning a string (and change it to stop it mutating). And then adding a #roundToDecimalPlaces (or similar) method to allow for the functionality that you want? |
Sounds perfect! |
Since Victor#toFixed() uses Number#toFixed() under the hood, it is turning the x and y coordinates of the vector into strings: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
The text was updated successfully, but these errors were encountered: