All language subtitles for 012 Annotating Argument Types_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

In the last section, we took care of our shuffle function by relying upon some functionality that was

implemented in the standard library.

We're not going to move on to our next function, which is cards with suits.

Let's take a look at a diagram that's going to give you a better idea of the purpose of this function.

So I want you to imagine for a second that maybe we have this deck of cards shown at the top.

So ace of diamonds, two, three, and then ace of spades and two of spades.

If we call the cards with method on the deck class in passing a string of spades, then I would expect

to receive a list back to me with the ace of spades and the two of spades.

So essentially go through the deck and find all the cards with a particular suit.

Now, one thing I want to mention here is that we do not want to modify the original deck of cards,

so we're not trying to pull cards out of here.

I just want to get a list telling me all the cards with a particular suit that still exist inside the

deck.

OK, so let's go back over to Arpad Pad and we're going to start our implementation.

So back over here, I'll find my deck class, I'm going to add a new method to this class down at the

very bottom of the class itself.

And I'm going to call this cards with suit.

Now, as we just saw in that diagram two seconds ago, right over here, we clearly have to pass in

a string that indicates what suit we're trying to find.

So I'm going to make sure that I marked this method as requiring one argument that we will refer to

as simply suit.

So now, if you want to call the cards with suit method, you have to pass in some suit arguments.

One thing I want to mention here is that if you click on a suit and then look down at the type on the

bottom right hand side, it says dynamic suit.

The word dynamic here means that Dart is not able to figure out what type of variable suit is supposed

to be.

So this is a good example of where Dart's going to try to figure out what's going on with your code,

but it's not quite able to any time.

Dart does not have enough information to figure out what your code is trying to do.

I recommend annotating your values with a type.

We've already done this a couple of times inside of our project already.

You'll notice that, say, on the card class right here.

We specifically marked this suit as being type string and that gave Dart enough information to figure

out what type the suit property was supposed to be.

But in this case, we don't have enough information, and so I'm going to specifically mark this argument

as simple as requiring to be of type string.

So I want to make sure that if you ever call this cards with such argument, you pass in a single argument

that is a string.

So to do so.

All right.

Out string and then suit.

So now if I click on it again, you'll notice that it says string suit.

So we've now given darte enough information to figure out what type of variable suit is right here.

OK, so now that we are inside of our cards with suit method and we have the appropriate type of argument,

we can now write some logic to go into our list of cards and find every card with a given suit.

Now, you might be thinking that we're going to have to put together a for loop or something crazy like

that and iterate over all the cards within our deck.

But rather than doing that, we're going to, again, rely upon the standard library, particularly

some functionality that we get with every list for free.

So I'm going to, again, pull up the list documentation.

Remember, you can get here by going to API, darling Doug, and then you'll look for the dart core

module right here.

And then you can find the list section on the right hand side.

So once I'm back here, I'm going to scroll down towards the very bottom of the file.

So all the way down here, right above the operators section, I'll find a method called where?

So the we're method right here is going to return a new lazy iterable, let's don't worry about what

a lazy iterable is just yet.

It's essentially kind of something like a list.

But more importantly, it says that it's going to return an iterable with all the elements that satisfy

some given test.

So we're going to make use of this where method right here to automatically iterate through all the

items within our carts list and only return the items that satisfy some test that you and I are going

to write.

So let's take a pause right here.

We're going to come back the next section and we're going to start our implementation of this where

method.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.