Is it unable to define objects using a "class" keyword on the p5.js mode on Processing

I use the p5.js mode on Processing 3.5.4, and run a sample “ex02_Multiple_Objects” from a Objects group.
I get the following error:
SyntaxError: Expected an operand but found class.

If I open index.html on a browser (Chrome and Safari) from a sketch folder, it works fine.

I can not understand the reason. Is this the specification of the p5.js mode on Processing IDE? Is it unable to define objects using a “class” keyword on the p5.js mode on Processing IDE?

Thank you in advance.

1 Like

It sounds like either:

  1. your sketch in PDE does not have “p5.js mode” selected, and you are running in e.g. Java mode
  2. you accidentally made a change to the example and saved it, deleting lines immediately before the class line. “Expecting an operand” means the compiler was looking for e.g. ‘+’ – that shouldn’t happen if the last thing was a function closing correctly with }

There are more exotic possibilities, but those are guesses to start. If you cut and paste the example into the editor.p5js.org, what happens?

Thank you for your reply.
What you wrote is exactly right, but my situation is not either.
I use Processing 3.5.4 with p5.js mode 1.2.2 on Windows 10.
If I run a code for ex01_Objects in “Sample” on the editor.p5js.org, it works. However, I want to use p5.js mode in Processing IDE. Is there any problem in p5.js mode in Processing IDE?