Add class method and tests for p5.Vector.toString() #5348
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #4852
Changes
Add tests for
p5.Vector.prototype.toString()
Add class method and tests for
p5.Vector.toString()
Notes
Adding class method
p5.Vector.toString()
for consistency's sake, as per #4852, but noticed that this has the small side effect of overriding the inherited default method fromFunction.prototype.toString()
, which returns the code that defines a function. I think it's unlikely anyone depends on that original behaviour, but since it's a breaking change I figured I'd split this particular change off of the rest of the static/class methods in #5044. This way we can discuss it separately.One weird ramification is that defining
p5.Vector.toString = (v) => v.toString()
caused problems with unit tests for instanceof p5.Vector - I haven't dug in to figure out why, but I did find out thatp5.Vector.toString = (v) => String(v)
seems to work just fine. Strange, right?PR Checklist
npm run lint
passes