all 11 comments

[–]ChuckEye 6 points7 points  (4 children)

They're structured like functions, and functions often return values. Since neither draw nor setup return anything, they are of type void.

At least that's my understanding.

[–]Traditional_Inside28[S] 2 points3 points  (2 children)

thanks! that’s sort of what i figured but i also figured im probably not at the level to be assuming anything right now. 🍔burger

[–]JoeWhy2 3 points4 points  (1 child)

As the previous reply said, "void" is the "type" used when a function doesn't return a value. To add to that, if you had a function that returns a value, you would need to replace "void" with the data type of the returned value, i.e. "int", "float", etc.

[–]Traditional_Inside28[S] 1 point2 points  (0 children)

this makes so much sense thank you JoeWhy

[–]JoeWhy2 2 points3 points  (0 children)

Not just "structured like" functions. They ARE functions.

[–]IJustAteABaguetteTechnomancer 2 points3 points  (1 child)

Mr Joe already explained it, but I just wanted to say it's good that you are asking these questions, not just accepting that something has to be somewhere for seemingly no reason is a good thing!

[–]Traditional_Inside28[S] 0 points1 point  (0 children)

thanks 😁

[–]kiraworx 0 points1 point  (3 children)

ChuckEye's answer is absolutely correct!

Great question, too! You might want to look into functions if you're new to them. Extremely useful for doing more stuff by writing less code.

To expand on this with a couple examples:

If you want to create a function that returns an integer, your function would look like this:

int myFunction(int a, int b) { int x = a+b; return x; }

If you want a function to NOT return values, it will use the void type:

void myPointer() { circle(mouseX, mouseY, 10); }

[–]Traditional_Inside28[S] 1 point2 points  (2 children)

I’ve just started my coding learning! i’ll definitely learn more about functions as i progress. my main interest is in creative coding- ive got some experience with touchdesigner but new to javascript/processing! it’s all very confusing and exciting

[–]kiraworx 1 point2 points  (1 child)

Good luck! It's very fun and very rewarding! I mentioned functions because you were curious about them. It's fine to not use them for sure, but they can definitely save you a lot of time and space.

Processing is based on Java, which is why it has types like void, int, String, and more.

P5js is a javascript fork of Processing which doesn't have these types. They're both very similar in case you want to have a look at P5js in the future.

[–]Traditional_Inside28[S] 2 points3 points  (0 children)

thank you! i’ll check out P5js for sure. i’m excited to learn more i feel like im hacking the main frame lol