Appendix. Variable Naming Rules

Here are the rules for variable names (also called identifiers):

  • They must begin with either a letter or an underscore character. Following that, you can use an unlimited sequence of letters, numbers, or underscore characters.
  • The letters can be uppercase or lowercase, and case matters. In other words, Ax is not the same as aX.
  • The numbers can be any of the digit characters from 0 to 9 inclusive.

Aside from letters, numbers, and the underscore character, no other characters can be used. Spaces, punctuation, and other characters are not allowed in variable names:

~ ` ! @ # $ % ^ & * ( ) ; - : " ' < > , . ? / { } [ ] + = /

The only special character that’s allowed is the underscore character. In case you don’t ...

Get Hello World! now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.