Game Development Reference
In-Depth Information
String variables
There is another kind of variable that is really important. This type of variable is called a
string variable . String variables are variables that comprise letters or words. This means
that if you want to record a character's name, then you will have to use a string variable. In
most programming languages, string variables have to be in quotes, for example, "John
Bura" . The quote marks tell the computer that the characters within are actually strings
that the computer can use.
When you put a number 1 into a string, is it a real number 1 or is it just a fake number? It's
a fake number because strings are not numbers—they are strings. Even though the string
shows the number 1, it isn't actually the number 1. Strings are meant to display characters,
and numbers are meant to do math. Strings are not meant to do math—they just hold char-
acters. If you tried to do math with a string, it wouldn't work (except in JavaScript, which
we will talk about shortly).
Strings shouldn't be used for calculations—they are meant to hold and display characters. If
we have a string "1" , it will be recorded as a character rather than an integer that can be
used for calculations.
Search WWH ::




Custom Search