Chapter 2 | Identifiers in Dart
If we want to make identifiers in Dart, we need to follow some rules.
- Identifiers can include both, characters and digits. However, the identifier cannot begin with a digit.
- Identifiers cannot include special symbols except for underscore ( _ ) or a dollar sign ($).
- Identifiers cannot be keywords.
- They must be unique.
- Identifiers are case-sensitive.
- Identifiers cannot contain spaces.
Here’s the source code (wait for it load):
Some examples of Valid Identifiers in Dart:
- firstName
- first_name
- num1
- $num1
- Var
Some examples of Invalid Identifiers in Dart:
- var // because it is pre-defined keyword in dart
- first name // because it contains space
- first-name // because it contains special character `-`
- 1number // because it starts with a number
Great, in this chapter we learned about Identifiers. So, this is it for this chapter. Bbye, see you in the next one.