What Does Lexical Structure Mean?
It’s not as complex as it sounds. Every programming language has a lexical structure, which is a set of basic rules you must follow when you’re writing code in a language such as how to write comments and name variables.
Semicolons Are Optional
Semicolons are generally used to indicate the end of a statement but they are not mandatory. You will not encounter an error if you were to choose to not end a variable you declare with a semicolon. I personally use semicolons because to me it makes code more readable for my eye but you don’t have to use them.
The spelling of the names of your variables, functions, keywords and other identifiers must be exact. So that means myName and MyName are not the same. Another example is with booleans, a topic we’ll be touching on later in the series. If we were to set a variable to True instead of true, you would encounter an error.
There are 2 different ways to create comments. You can either make a single line comment using 2 forward slashes or create a multi-line comment using a forward slash and an asterisk to create longer, more meaningful comments if you need to.
What Are Identifiers?
Identifiers are names. It’s how we create references to our variables and functions. You can start any variable name with a dollar sign, underscore or letter. The main rule is to not use numbers as the first character in our identifiers.
A literal is a piece of data that appears directly in a program such as numbers, strings (text encapsulated by quotation marks), boolean values and null.
So…What are we learning next?
So next we will continue on diving deeper into the primitive data type strings and the different ways we can manipulate them so this will get way more fun and practical! Thanks for reading, hope you enjoyed!