All language subtitles for 016 Shorthand Function Syntax_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
ru Russian Download
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 had a deep discussion on how this sublist method right here actually works.

So when it says that it returns a new list containing the objects from a START index to an end index,

we now understand that it's not actually kind of copying those objects.

It's not removing them from the original list.

We are just copying references to those objects and they never get removed from the original list.

So with that in mind, we're now going to flip back over to Darte Pad and we're going to implement our

deal method.

We're going to figure out how to actually modify our original underlying deck when we create this hant,

because as we just discussed a moment ago, if ideal, use some number of cards out of my deck like,

say, cards zero, one and two.

I definitely should not retain access to those cards when I deal them to you.

That's it.

They're no longer inside of my hand of cards or my deck of cards.

I no longer have access to them.

OK, so I'm gonna flip back over to Arpad.

I'm going to find my deck class.

Here it is right here.

I'm going to go down to the bottom of that class again.

And while still inside of the class body, I'm going to create a new method called Deal.

Now, whenever we call this deal function right here, we probably need to know how many cards we're

trying to deal out to a user.

For example, if we are playing a game of poker, I might need to deal you five cards.

But if we're playing a game of blackjack, I'll probably only deal you like, what, two cards or whatever

it's supposed to be.

So as an argument to this deal function, I'm going to expect to receive an integer reflecting the hand

size or how many cards I'm supposed to deal into your hand.

OK, so that looks good now the next thing we're going to do is we're going to take our cards list and

we're going to call that sublist method on it.

We're actually going to call the sublist method on it two times.

Let me give you a quick diagram of how this thing's going to work.

We're going to call this sublist method two times the first time you and I are going to pull out some

number of cards that are going to be returned to whoever called this function.

Then we're going to call the sublist method a second time, and in that second call, remember that

we're not actually removing these cards per say.

So let me copy paste them back up here to reflect reality.

So in the first sublist call, we're going to create the second list down here or this kind of hand

that we're going to return.

And then in a second call to Sublist, we're going to pull off all the remaining cards.

So like three, four or five over here, that's going to give us a new list.

We're going to take that list and assign it over the current cards list.

So in other words, we're going to call Sublist the second time.

We're going to get a new list over here.

We're going to throw this old list away, and then we're going to say that the new cards list that belongs

to our deck class is just these remaining three, four and five.

So essentially, we're just going to call Sublist twice and make use of these two different slices.

One is going to go to whoever called the deal method and the other is going to go to the cards property.

On our debt class.

I think that once we write out the code for this, it'll make it a lot more sense.

So down here inside of deal are going to first create my hand of cards or come to the deck or the list

of cards that we're going to return from this function.

So we'll save our hand is cards, dot sublist.

And I'm going to take all the cards from zero to hand size like so.

So with this line of code right here, we are creating a new list and we are copying references over

to that new list and we assign all that to hand.

Then after that, I'm going to call cards dot sublist again and we're going to take all the cards that

are remaining inside this hand.

Starting at hand size, so notice how right here we took everything from the start to hand size, then

on Sublist right here, we're going to take everything that is remaining in the deck.

So we'll say hand size on now for going all the way to the end of the list here or getting all the remaining

cards if you go back and look at the documentation here.

You'll notice that around the house, I accidentally clicked on it.

I apologize.

Let's stop now.

Go back.

OK, so around that second argument.

There we go around the second argument, we've got a set of square braces right there, so whenever

you see the square braces around an argument list, that means that it is an optional argument.

So in other words, if we do not pass in in any argument right here, sublist is going to automatically

go all the way to the very end of the list and take everything that is remaining inside there.

So all we have to do is pass in sublist as the first argument right here.

And then we do not have to pass in a second argument.

So this line of code right here is going to take all the remaining cards inside of our cards list,

and then we're going to take that brand new list that gets returned and we're going to overwrite our

current list of cards with that one.

And then finally.

We will return the hand that we created.

And that's pretty much it.

OK, so let's test this out now and go back up to my main method, I'm going to do a little bit of changing

inside of our main method here.

Let's just go back to where we had the deck.

I'll start off by printing the deck.

So we'll just kind of start off and say, hey, what do we have here?

I'll then call print on deck deal and I'll try to deal myself five cards.

So now we're going to see to print statements.

We'll see the original deck completely unmodified.

We'll then see a hand of just five cards or a list of five cards by itself.

And then we'll print out the deck again.

So the second deck right here should have five fewer cards inside of it because we took five cards and

we dealt them out to, I don't know, someone who's playing our game, presumably.

All right.

So let's give this a shot or click run up here.

Give it a second.

It gets stuck all the darn time.

Let's try this again.

There we go.

Much better.

OK, so right here, you'll see here is our original list of cards.

That's all the cards that we're create inside of our deck.

Then right here, I see one, two, three, four and five cards that were created inside of our hand.

And then we see right here, there's clearly I'm not going to count them all out, but clearly there

are fewer cards inside of here and there.

So we can kind of make a quick comparison here.

Notice how in the original list we had five Dimond's cards.

Those diamonds are now inside the hand and they are no longer inside of the list of cards that belong

to our actual deck class.

OK, so I know that this sublist stuff was a little bit crazy, but remember the overall goal of what

we were trying to communicate here is that whenever we create a list of records, the list does not

actually truly store our records.

The records exist inside of memory and the list just makes reference over to the records.

OK, so now that we got a better handle on that, let's continue in the next section.

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