processing / processing/processing-website

Confusing example for PVector copy() method

Open
#577 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Examples Good First Issue Help Wanted
Dominant language
MDX
Stars
90
Forks
122
Avg merge
1h 43m
Merged PRs (30d)
3

Description

Select the type of content error.

Other content error (please specify)

Section

Examples

Location of the error

https://processing.org/reference/PVector_copy_.html

Describe the error

In the documentation for the copy() method of the PVector class, the following code example is given:

PVector v1, v2;

void setup() {
  size(100, 100);
  v1 = new PVector(20.0, 30.0, 40.0);
  v2 = new PVector();
  v2 = v1.copy();
  ...

While not a factual error, it seems curious to me that v2 would be instantiated as a new PVector only to be assigned the result of v1.copy(). If .copy() creates a returns a new PVector object, then the initial assignment would have no effect. This led to some confusion amongst my students who had various incorrect assumptions about how .copy() works given the example code.

Suggested correction
PVector v1, v2;

void setup() {
  size(100, 100);
  v1 = new PVector(20.0, 30.0, 40.0);
  v2 = v1.copy();
  ...
Language

No response

Screenshots or references

No response

Additional context

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the PVector copy() reference page linked in the issue and locate its Examples section. Check the example's object initialization and copy assignment, then update the example so it no longer performs the redundant initialization. Verify the rendered documentation example after the change.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.