Variable names

I am trying to find which is a valid option and am not able to find the answer.
The 2 options are Sum_ and _s_u_m_. I'm thinking it is _Sum but looking for the reason why.

Thanks in advance for your help.
What do you mean by "valid option"?
Both are valid variable names.

Variable names that begin with underscore are generally reserved for the implementation.
Last edited on
OK thanks. I knew the options to start a variable had to be a letter or (_) underscore, could find any rules about how the variable ended. I was told only one option was invalid. Thanks for your help.
In user code:

Sum_ is a valid name everywhere.

_s_u_m_ is not a valid name if it is in the global namespace; anywhere else, it is a valid name.

_Sum is not a valid name anywhere.

Certain sets of names and function signatures are always reserved to the implementation:

— Each name that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use.

— Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
Topic archived. No new replies allowed.