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 broke down this line of code right here, remember, the VA name is referred
to as variable declaration because it creates a new variable then the equals.
My name is referred to as variable initialization because it assigns a value to that new variable that
was just created.
At the end of this line, we had a call to the my name function, which was defined down here at the
bottom of the file.
So in this section, we're going to start to take a look at this function declaration down here.
Now, I don't have a terribly large amount to say about functions, mostly because they work almost
identically to how they work and just about every other style language out there, every function we
create can have a name assigned to it.
So in this case, the name of our function is simply my name.
After the name of the function, we then place a set of parentheses which denotes the argument list,
so any time we call a function, we can pass in some number of arguments to it.
We then have a set of curly braces which form the function body.
So inside those curly braces is where we add all the code that's going to be executed any time we call
this function.
And where things start to get a little bit interesting is the word string over here to the left hand
side.
So any time our function returns a value, we can annotate that function with the type of value that
is going to be returned in this case, we are returning a string from the function.
So we wrote out the left hand side of the function name string, because that is the type of value that
we're going to return any time this function gets called.
We're going to have a discussion about type's in just a second, but before we do, I want to mention
one other thing about functions in darte.
Back over here, you'll notice that we had a function called Main, and then we had also defined a second
function called my name in general.
You and I can name functions, anything we wish.
But there's exactly one exception to that rule, and that is the main function in darte.
The main function is a very special function that has to be defined inside of every darte program that
we ever put together.
The main function right here is automatically invoked by darte any time our program is executed.
And so you can kind of think of the flow of operations as being something like this.
So we're up here at the top.
Our program starts up darte, is going to look over all the code inside of our application and try to
find a function called main.
If it finds it, it's then going to run it.
And from that main function, you and I can add some code to do some actual up of our application and
accomplish whatever app is really trying to do.
Now, one thing I want to mention here is that every darte program we put together has to have a main
function.
So, for example, if I take this entire main function back here and delete it and then click run again.
You'll notice that I get an error message over here on the right hand side that says uncaught and essentially
it's an error message that's complaining that there's no main function defined inside of my project.
If I go back to having the main function and run it again, I'll then see the expected output of my
name is Stephen.
So in closing, functions for the most part behave very similar to how they do in just about every other
language out there.
The one requirement of every program is that we have to have one function called main.
The only thing that's kind of unexpected about these functions is that they have to annotate their return
type with a type being listed just to the left of the function name.
Now, let's take a pause right here.
We're going to come back to the next section and we're going to start talking a lot more about how types
work in DART.
So a quick break and I'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.