Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Looks like a C-style Processing. Yes, you should be able to do that with no problems.
-
compSci9595yThose specific functions are called during the execution of the project regardless of whether you call it.
Draw & setup are called automatically.
Similar to how func main works in package main in GO.
Void flashing will only be executed if you call it. That’s the difference between the three. But yes any word can follow void unless it’s another semantically incorrect key word. -
SomeNone7135yI think you need to go back to reading about the basics… in C-style programming languages, a function/method definition is a return type, followed by the function/method name, followed by the argument list in parentheses (possibly empty), followed by the function/method body (typically enclosed in curly braces).
While 'void' is somewhat crippled compared to other types, in this context it is just a return type, and the name you give to the method/function doesn't technically have any limitations resulting from the return type being void. -
m3b6355yWhen you click run, the Processing IDE will compile your pde files to java. It does that by simply coping the content of all your pde files into a template (see image).
Thus, every "function" you write, will become as method of the class and every "global var" will become an attribute of the class. When you write custom classes, they will become inner-classes.
And to answer your question. Every method in java needs to have a return type. When you want to return nothing, you need void.
Fix: "Pipes" in line 20 needs to be replaced with "Name". -
m3b6355y@m3b6 I have missed answering which method names are allowed. You can look up the grammar here: https://docs.oracle.com/javase/.... Essential you can use A-Z, a-z, underscore (_), dollar sign ($), and 0-9. But you can not start with a digit.
Valid: thisisamethodname
Valid: $hi
Valid: this_is_a_method$
Valid: thisIsA02923_method$
Invalid: 012
Invalid: 021hi
$ and _ are there for historic reasons and not recommended. -
setup and draw are "keywords" in processing but from the perspective of Java they are just methods that are always going to get called when you run your PApplet (a.k.a. sketch)... and since they are just methods they need to have a return type, the return type of void means they don't return anything, as for the flashing method, you can use basically any name you want unless it is a Java keyword
Great way to learn Processing is watching videos by one of the members of the Processing Foundation - Daniel Schiffman and also just by reading the reference at processing.org (there are examples for every method, keyword and type that exists in processing)
Related Rants
So the lecturer refused to answer(yes he's a jerk) but after void can it be anyword for a function or is there specific words that can only be used?
I was confused when he put void flashing...
We were using processing.
question
code
newby coder
university life
coding question
processing