- The right way to call a function with no arguments
- Immediately execute anonymous functionality, like in a switch statement
CS is very sparse in its use of parenthesis; calling functions with arguments makes clear sense, but it's not immediately clear how functions without arguments get called. Check out the two lines of code:
There is the CS way to do things! Calls the function perfectly. "do" Helps us elsewhere too:
Immediately Call Anonymous Functionality:
In a similar fashion, there are times when an anonymous function is immediately called, as opposed to in a callback fashion. I'll just show the code:
Again, "do" is the secret weapon here. When supplying callback function to CS, you can just specify inline without "do." But in the case of the switch statement it needs to called immediately, hence the keyword.
Those are the two cases that I was able to find, but perhaps there are more ways "do" is used in CS. Did I miss anything?