Variables
When you start learning to program, one of the first things you’ll learn about is variables. A variable can be visualized as a box, that contains something.
Different programming languages can have different approaches for what is needed to declare a variable. Usually, you’ll specify the datatype and giving it a name and in many cases a value it should hold:string name = "Kenneth";
In this case, the box would be labeled “name” and inside there would be the string (text) “Kenneth”.
Variables, as the name implies is variable and can be changed 😀
Let’s say you have an app with a countdown for days left to an event you’re excited for:int daysToGameRelease = 30;
It wouldn’t be very helpful if it always stayed at 30, would it? So let’s change it!daysToGameRelease = 29;
notice how I didn’t specify the type when changing it since the program already knows what daysToGameRelease
is.
Datatypes
Above I mentioned specifying the datatype when declaring a variable, this limits what sort of things you can store in the box. Similar to how you would not store your dirty dishes in your underwear drawer (at least I would hope not 😅). The underwear drawer is for items with the type of underwear, and the sink better suited for the dirty dishes type! 😁
There are several built-in datatypes for dealing with text and numbers as well as a boolean type. And everything is built on these in one way or another.
There are further sub-divisions where some types are better suited for some cases than others.
A short one today, thanks for reading :)