Skip to content

Correct set() documentation#8838

Merged
ksen0 merged 1 commit into
dev-2.0from
set-docs
May 28, 2026
Merged

Correct set() documentation#8838
ksen0 merged 1 commit into
dev-2.0from
set-docs

Conversation

@ksen0
Copy link
Copy Markdown
Member

@ksen0 ksen0 commented May 28, 2026

Testing 2.3.0-rc.6 with this nature of code example, Discord/sidwellr found using set() according to docs resulted in "mismatched dimension" FES warnings from the binary vector operations.

Discord/sidwellr suggested:

Change the first paragraph "Sets the vector's x, y, and z components." to "Sets a vector to a new value."

Change the third paragraph "If a value isn't provided for a component..." to something like:

The vector will be replaced with the new one, which might have a different number of dimensions. For example, v.set(4, 5) will set v to a two dimensional vector vector[4, 5]. v.set(v2) is similar to v = v2.copy() (but works even if v is a const). Calling v.set() with no arguments sets v to an empty vector.

@limzykenneth said:

Agreed for the first paragraph change, it shouldn't mention x, y, z components any more (I changed those for mult etc already).

For the third paragraph suggestion, I'm not sure conceptually "vector will be replaced with the new one" is the right wording. While the vector's dimension may change and so it technically would be a different vector, the vector object itself is not replaced ie. v === v is still true. Implying the vector is replaced for me implies v !== v. Same with implying v = v2.copy() which creates another vector and violates v === v.

function setup() {
  createCanvas(400, 400);
  v = createVector(1, 2);
  v2 = v;
  v.set(2, 3);
  console.log(v === v2); // This is true
}

The PR changes the first paragraph, and removes the third, because the current version is actively misleading.

@ksen0 ksen0 marked this pull request as ready for review May 28, 2026 14:23
@p5-bot
Copy link
Copy Markdown

p5-bot Bot commented May 28, 2026

Continuous Release

CDN link

Published Packages

Commit hash: daf4874

Previous deployments

This is an automated message.

@ksen0 ksen0 merged commit bf8b0d4 into dev-2.0 May 28, 2026
8 checks passed
@ksen0 ksen0 deleted the set-docs branch May 28, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants