Nimrod Programming/Basic type
Typing types
[edit | edit source]So now let's introduce a new concept, types. Types are categories of data, indeed we have already used some of them, string, Boolean and int. Using them is easy, we just need to change how we declare variables. Up until know we have been doin something like this:
var myVar = "This is a string"
But we can also do this:
var myVar:string
myVar = "This is a string"
Or even this:
var myVar:string = "This is a string"
As you may know, Nim needs to know what kind (type) of variable it is before making the executable (because the resulting program is faster that way) and it can't be changed the type after that. Now we have all sort of technical names for those attributes, but this is generally called static typing, and we say Nim it's a statically typed language (one in which the types of variables won't change). This may sound very confusing, types? static typing? What?? But let it be a moment and it may start to make sense (if not don't worry it will end up doing that).
Well we know what a type is, though, how we do know what types are available to us, in order to play with them? Well, we are going to list them, however for now we are going to introduce only the most basic ones (which are pretty much the same for every language):
Numbers
[edit | edit source]In order to have an efficient way of representing numbers there are several kinds of numbers:
This page or section is an undeveloped draft or outline. You can help to develop the work, or you can ask for assistance in the project room. |