All language subtitles for 016 Shorthand Function Syntax_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian Download
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,100 --> 00:00:05,660 In the last section, we had a deep discussion on how this sublist method right here actually works. 2 00:00:06,080 --> 00:00:12,230 So when it says that it returns a new list containing the objects from a START index to an end index, 3 00:00:12,440 --> 00:00:16,430 we now understand that it's not actually kind of copying those objects. 4 00:00:16,640 --> 00:00:18,890 It's not removing them from the original list. 5 00:00:19,310 --> 00:00:25,250 We are just copying references to those objects and they never get removed from the original list. 6 00:00:25,780 --> 00:00:29,540 So with that in mind, we're now going to flip back over to Darte Pad and we're going to implement our 7 00:00:29,540 --> 00:00:30,320 deal method. 8 00:00:30,580 --> 00:00:36,560 We're going to figure out how to actually modify our original underlying deck when we create this hant, 9 00:00:36,920 --> 00:00:43,100 because as we just discussed a moment ago, if ideal, use some number of cards out of my deck like, 10 00:00:43,100 --> 00:00:45,080 say, cards zero, one and two. 11 00:00:45,350 --> 00:00:49,700 I definitely should not retain access to those cards when I deal them to you. 12 00:00:49,730 --> 00:00:50,300 That's it. 13 00:00:50,300 --> 00:00:54,070 They're no longer inside of my hand of cards or my deck of cards. 14 00:00:54,080 --> 00:00:55,910 I no longer have access to them. 15 00:00:56,490 --> 00:00:58,190 OK, so I'm gonna flip back over to Arpad. 16 00:00:58,880 --> 00:01:01,210 I'm going to find my deck class. 17 00:01:01,220 --> 00:01:02,000 Here it is right here. 18 00:01:02,600 --> 00:01:04,819 I'm going to go down to the bottom of that class again. 19 00:01:05,950 --> 00:01:10,990 And while still inside of the class body, I'm going to create a new method called Deal. 20 00:01:12,590 --> 00:01:17,180 Now, whenever we call this deal function right here, we probably need to know how many cards we're 21 00:01:17,180 --> 00:01:18,550 trying to deal out to a user. 22 00:01:18,950 --> 00:01:23,600 For example, if we are playing a game of poker, I might need to deal you five cards. 23 00:01:23,990 --> 00:01:28,850 But if we're playing a game of blackjack, I'll probably only deal you like, what, two cards or whatever 24 00:01:28,850 --> 00:01:29,520 it's supposed to be. 25 00:01:30,350 --> 00:01:38,150 So as an argument to this deal function, I'm going to expect to receive an integer reflecting the hand 26 00:01:38,150 --> 00:01:41,960 size or how many cards I'm supposed to deal into your hand. 27 00:01:44,240 --> 00:01:50,060 OK, so that looks good now the next thing we're going to do is we're going to take our cards list and 28 00:01:50,060 --> 00:01:52,190 we're going to call that sublist method on it. 29 00:01:52,530 --> 00:01:55,460 We're actually going to call the sublist method on it two times. 30 00:01:56,480 --> 00:01:58,880 Let me give you a quick diagram of how this thing's going to work. 31 00:01:59,600 --> 00:02:05,780 We're going to call this sublist method two times the first time you and I are going to pull out some 32 00:02:05,780 --> 00:02:10,250 number of cards that are going to be returned to whoever called this function. 33 00:02:11,270 --> 00:02:16,820 Then we're going to call the sublist method a second time, and in that second call, remember that 34 00:02:16,820 --> 00:02:18,920 we're not actually removing these cards per say. 35 00:02:18,920 --> 00:02:22,730 So let me copy paste them back up here to reflect reality. 36 00:02:23,240 --> 00:02:27,170 So in the first sublist call, we're going to create the second list down here or this kind of hand 37 00:02:27,170 --> 00:02:28,020 that we're going to return. 38 00:02:28,460 --> 00:02:33,760 And then in a second call to Sublist, we're going to pull off all the remaining cards. 39 00:02:34,310 --> 00:02:38,660 So like three, four or five over here, that's going to give us a new list. 40 00:02:38,870 --> 00:02:43,940 We're going to take that list and assign it over the current cards list. 41 00:02:43,970 --> 00:02:46,280 So in other words, we're going to call Sublist the second time. 42 00:02:46,790 --> 00:02:48,260 We're going to get a new list over here. 43 00:02:48,680 --> 00:02:54,380 We're going to throw this old list away, and then we're going to say that the new cards list that belongs 44 00:02:54,380 --> 00:02:57,910 to our deck class is just these remaining three, four and five. 45 00:02:58,310 --> 00:03:02,510 So essentially, we're just going to call Sublist twice and make use of these two different slices. 46 00:03:02,810 --> 00:03:08,960 One is going to go to whoever called the deal method and the other is going to go to the cards property. 47 00:03:09,900 --> 00:03:11,010 On our debt class. 48 00:03:12,050 --> 00:03:14,950 I think that once we write out the code for this, it'll make it a lot more sense. 49 00:03:15,560 --> 00:03:22,130 So down here inside of deal are going to first create my hand of cards or come to the deck or the list 50 00:03:22,130 --> 00:03:24,170 of cards that we're going to return from this function. 51 00:03:24,720 --> 00:03:28,370 So we'll save our hand is cards, dot sublist. 52 00:03:29,030 --> 00:03:34,850 And I'm going to take all the cards from zero to hand size like so. 53 00:03:36,060 --> 00:03:41,460 So with this line of code right here, we are creating a new list and we are copying references over 54 00:03:41,640 --> 00:03:44,580 to that new list and we assign all that to hand. 55 00:03:46,030 --> 00:03:52,360 Then after that, I'm going to call cards dot sublist again and we're going to take all the cards that 56 00:03:52,360 --> 00:03:53,980 are remaining inside this hand. 57 00:03:55,040 --> 00:04:02,360 Starting at hand size, so notice how right here we took everything from the start to hand size, then 58 00:04:02,360 --> 00:04:06,740 on Sublist right here, we're going to take everything that is remaining in the deck. 59 00:04:06,770 --> 00:04:12,890 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 60 00:04:12,890 --> 00:04:15,500 cards if you go back and look at the documentation here. 61 00:04:16,450 --> 00:04:20,980 You'll notice that around the house, I accidentally clicked on it. 62 00:04:21,010 --> 00:04:21,680 I apologize. 63 00:04:21,730 --> 00:04:22,700 Let's stop now. 64 00:04:22,720 --> 00:04:23,290 Go back. 65 00:04:24,280 --> 00:04:26,410 OK, so around that second argument. 66 00:04:27,670 --> 00:04:32,110 There we go around the second argument, we've got a set of square braces right there, so whenever 67 00:04:32,110 --> 00:04:36,950 you see the square braces around an argument list, that means that it is an optional argument. 68 00:04:37,390 --> 00:04:43,060 So in other words, if we do not pass in in any argument right here, sublist is going to automatically 69 00:04:43,060 --> 00:04:47,710 go all the way to the very end of the list and take everything that is remaining inside there. 70 00:04:48,490 --> 00:04:52,270 So all we have to do is pass in sublist as the first argument right here. 71 00:04:52,420 --> 00:04:55,300 And then we do not have to pass in a second argument. 72 00:04:56,340 --> 00:05:01,230 So this line of code right here is going to take all the remaining cards inside of our cards list, 73 00:05:01,830 --> 00:05:06,360 and then we're going to take that brand new list that gets returned and we're going to overwrite our 74 00:05:06,360 --> 00:05:07,860 current list of cards with that one. 75 00:05:09,080 --> 00:05:09,860 And then finally. 76 00:05:11,030 --> 00:05:13,970 We will return the hand that we created. 77 00:05:14,890 --> 00:05:15,810 And that's pretty much it. 78 00:05:17,970 --> 00:05:24,030 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 79 00:05:24,030 --> 00:05:25,400 inside of our main method here. 80 00:05:25,680 --> 00:05:27,660 Let's just go back to where we had the deck. 81 00:05:27,870 --> 00:05:30,000 I'll start off by printing the deck. 82 00:05:30,000 --> 00:05:33,060 So we'll just kind of start off and say, hey, what do we have here? 83 00:05:33,650 --> 00:05:39,510 I'll then call print on deck deal and I'll try to deal myself five cards. 84 00:05:40,310 --> 00:05:42,210 So now we're going to see to print statements. 85 00:05:42,240 --> 00:05:45,000 We'll see the original deck completely unmodified. 86 00:05:45,570 --> 00:05:50,520 We'll then see a hand of just five cards or a list of five cards by itself. 87 00:05:51,150 --> 00:05:52,890 And then we'll print out the deck again. 88 00:05:53,760 --> 00:06:00,270 So the second deck right here should have five fewer cards inside of it because we took five cards and 89 00:06:00,270 --> 00:06:03,940 we dealt them out to, I don't know, someone who's playing our game, presumably. 90 00:06:04,740 --> 00:06:05,040 All right. 91 00:06:05,040 --> 00:06:07,170 So let's give this a shot or click run up here. 92 00:06:09,640 --> 00:06:10,570 Give it a second. 93 00:06:13,480 --> 00:06:14,810 It gets stuck all the darn time. 94 00:06:14,830 --> 00:06:15,620 Let's try this again. 95 00:06:15,670 --> 00:06:16,090 There we go. 96 00:06:16,090 --> 00:06:16,540 Much better. 97 00:06:16,960 --> 00:06:20,620 OK, so right here, you'll see here is our original list of cards. 98 00:06:20,620 --> 00:06:22,810 That's all the cards that we're create inside of our deck. 99 00:06:23,230 --> 00:06:29,140 Then right here, I see one, two, three, four and five cards that were created inside of our hand. 100 00:06:29,740 --> 00:06:33,640 And then we see right here, there's clearly I'm not going to count them all out, but clearly there 101 00:06:33,670 --> 00:06:35,780 are fewer cards inside of here and there. 102 00:06:35,800 --> 00:06:37,550 So we can kind of make a quick comparison here. 103 00:06:37,690 --> 00:06:41,280 Notice how in the original list we had five Dimond's cards. 104 00:06:41,800 --> 00:06:47,260 Those diamonds are now inside the hand and they are no longer inside of the list of cards that belong 105 00:06:47,260 --> 00:06:48,940 to our actual deck class. 106 00:06:49,900 --> 00:06:55,960 OK, so I know that this sublist stuff was a little bit crazy, but remember the overall goal of what 107 00:06:55,960 --> 00:07:01,150 we were trying to communicate here is that whenever we create a list of records, the list does not 108 00:07:01,150 --> 00:07:03,790 actually truly store our records. 109 00:07:04,240 --> 00:07:09,310 The records exist inside of memory and the list just makes reference over to the records. 110 00:07:10,150 --> 00:07:13,840 OK, so now that we got a better handle on that, let's continue in the next section. 10867

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