0
What is the point of void?
I know "void" now as a tag or keyword, and vaguely understand that it has to do with voiding a return? but can this not also be done with = 0? I'm still getting my head around syntax, and just was curious if someone could offer me some insights on this one, please excuse my ignorance.
2 Antworten
+ 5
Void means not to return anything with the function.
0 is a value being returned, and usually that function will be an integer function.
A string function returns any string value. Same for other functions.
Void simply means there had nothing to return.
So if you call a void function, only the code is executed in that function. But if it is not void, a value is selected to be returned and can be assigned to a variable or used as an expression.
+ 4
Why return 0 when you don't need to? :>