Jump to content

Case-sensitivity of identifiers: Difference between revisions

Changed again the whole code.
m (Corrected typo.)
(Changed again the whole code.)
Line 984:
:– moreover, underline is ignored in identifiers (style insensitivity).
 
With these rules, we don’t get one dog or three dogs: we get two dogs!
<lang Nim># The guidelines suggest that type identifiers begin by an uppercase letter.
type Coordinates = tuple[x, y: float]
 
<lang Nim>var dog, Dog: string
# The guidelines suggest that variable identifiers start with a lowercase letter.
(dog, Dog, DOG) = ("Benjamin", "Samba", "Bernie")
var coordinates: Coordinates # No problem, the identifiers differ by their first letter.
if dog == Dog:
if dog == DOG:
echo "There is only one dog, ", DOG)
else:
echo "There are two dogs: ", dog, " and ", DOG
elif Dog == DOG :
echo "There are two dogs: ", dog, " and ", DOG
else:
echo "There are three dogs: ", dog, ", ", Dog, " and ", DOG</lang>
 
{{out}}
var x_y: COORDINATES # COORDINATES is the same as Coordinates.
<pre>There are two dogs: Benjamin and Bernie</pre>
xy = (2, 3) # Same as x_y.
echo xY # Also same as x_y.</lang>
 
=={{header|Oberon-2}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.