Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In the last section, we laid out a couple of different rules around Dart's type system in the section,
we're going to talk just a little bit more about types in particular.
We're going to look at some of the very basic types that are available to us in DART.
All right, here we go.
So on the left hand side of listed out a couple of very basic types and then on the right hand side,
we've got some example values of each one.
You and I have already taken a look at the string tight.
A string type is a series of characters that get put together into one value.
So an example of a string type would be, hi, how's it going?
And that's great.
One of the other very basic types that we're going to make use of in many of our programs is the int'l
type as well, which is short for integer and integer is any number negative, zero or positive that
does not have a decimal associated with it.
So an example of an inch would be zero negative nine nine nine or eight hundred and seventy six thousand.
One of the last very common types that we're going to work with quite a bit is the double type.
This is a number that has a decimal associated with it.
So the big difference between integer and double is the presence of some decimal.
Examples of doubles would be zero point zero zero one negative, ninety nine point eight one four.
And you get the idea.
Now, besides these very basic types, we also have this dynamic type, which we briefly discussed in
the last section, the dynamic type down here is still technically a type in dart.
The dynamic type means to say we have a variable that can hold any value that we wish.
So if we had a variable with a type of dynamic associated with it, that variable could reference any
type of value, like the string right here of high, the double negatives point zero zero zero four
or the integer 90.
Now, the last thing I want to mention very briefly about types before we move on to our next topic
is have a quick discussion about why we care about types at all.
This is probably one of the more important things to talk about, especially if you're coming from a
dynamic language like, say, JavaScript.
So let's very briefly talk about some of the benefits of using a type system.
One of the most market benefits is that whenever we use a type system, there is the possibility of
improving the performance of our application.
Even when you use JavaScript, which is a dynamic language when that JavaScript code is executed, the
interpreter that's executing that code is technically still doing some type, checking behind the scenes.
And so any time we use a dynamic, dynamic language, there is a performance penalty associated with
it.
By using a type system, we have the possibility of getting some improved performance.
Next up, it tends to be a little bit easier to work on large projects when they use a strong type system.
So if we're working on some very large project where we have to make use of some code written by another
engineer, it will be a lot easier if we could get a better idea of what the structure of data is that
comes back from some code.
There's whenever we execute it.
So if we're working on a large project with many engineers or even just a few, it tends to be a little
bit easier to work with a language that has strong typing.
Next, there tends to be slightly less of a need to write unit tests around any language that has strong
typing associated with it.
For example, if we're making use of Ruby or JavaScript, we might want to run a test that says that
any time we run some particular function, we always get back an array or a string or an integer.
So if we're using JavaScript, Ruby, we definitely would want to write a test like that to make sure
that in fact, yes, we get back an array or a string or whatever it is, but when we're making use
of a strongly typed language with Dart, we get a little bit more assurance that whenever we say that
some function is going to return, some specific value, chances are, yep.
In fact, it's going to return that type of value.
Finally and makes life a little bit easier for finding very simple errors, for example, if we go back
over to our dart pad project over here, let's say that right before we try to print up the string right
here, we tried to retrieve the length of this string that we return from the mining function.
So if I wanted to get the length of some particular string, I could write out name length like so.
Now, when I write this code out right here, Darte has the ability to look at the type of variable
that this very early in the type of value that this variable is referencing, DART knows that it is
of type string Daquan.
Then go check to see if String has a length property associated with it.
And in this case, yes, it does.
If we instead returned an integer from the mining function down here instead, like, say, INT.
And then returned the number one, two, three.
Now, the we're getting a nasty, nastier message from this line of code, because Dart is able to know
that name is now storing an integer and an integer does not have a length property associated with it.
So, again, by using a type system, we get a little bit better ability to find very simple errors
like that inside of our code.
Now, really quickly, back over here.
I am going to undo those changes I made.
Very good.
OK, so in this section, we spoke about some of the very basic types that are available to us inside
of DART, and we also spoke about why we care about using type systems at all.
So let's continue in the next section and we're going to take a look at the very last line of code inside
of our program, the print statement.
So quick break and we'll see you in just a minute.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.