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.

13th Jul 2018, 9:02 PM
Blake Larson
Blake Larson - avatar
2 odpowiedzi
+ 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.
13th Jul 2018, 9:18 PM
Andre Daniel
Andre Daniel - avatar
+ 4
Why return 0 when you don't need to? :>
14th Jul 2018, 5:12 AM
Hatsy Rei
Hatsy Rei - avatar