All language subtitles for 008 Void Functions vs. Value-returning Functions_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
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
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

All right.

Let us just jump right into it.

So here we've got two functions.

This one returns a double when called.

This one returns a string, one called.

But for the sake of variety, let us add another function.

But this one, unlike these two, is not going to return a value.

You guessed it, it's going to be void.

And this void function is going to be called print area.

And this function is not only going to print the area, but the length and width that we're used to

produce that area.

So it's going to need to define three parameters double length, double width and double area.

And you might be wondering why is this function void and why are these returning values?

I will get to that in just a second.

But bear with me here.

We're just going to print.

Um, a rectangle with a length of.

Length.

And a width of width.

As an area of.

Whatever area that gets passed in.

Okay.

So why is this void and why is this returning a value?

And why is this returning a value?

Well, as I mentioned before, a function should only be performing a single task.

This one performs the task of calculating an area.

The function is already performing a computation.

It should not be the one to also handle the final result of that computation.

It should return the final result and let whoever is calling the function to deal with that result as

they see fit.

The explained area function is performing one task.

It takes in a language and based on the provided language, it compares it against three possible cases

and it explains the area in their preferred language.

This is a form of computation.

The function is already doing so much work, so it should not be the one to handle the final result.

It should simply return the result of that computation.

Whenever a function is performing a calculation or a computation of some sort.

It should not handle the final result.

It should just return the result and let whoever is calling the function to deal with that result as

they see fit.

But the function print area, its only task is to print the area.

It's not performing any calculations, it's not performing any computations.

So we cannot expect it to return any values.

That's why it remains void.

Void means the function does not return a value when called.

It's simply going to print a message depending on what gets passed in.

So what we're going to do is we're going to keep this simple.

We're only going to call explain area once.

We're only going to call calculate area once.

When we calculate an area for the following length and width, we're going to print that area using

the print area function.

The first value that we pass in is the length.

The second value that we pass in is the width, and the third value that we pass in is the area that

was produced from the length and the width.

And here we're just going to print the English explanation normally.

All right.

Putting breakpoints here, here and here.

Re visualizing the runtime.

So when you calculate an area for a length of 2.3 and a width of 3.6, you get a value of 8.28.

And inside of the print area function, we're simply printing that a rectangle with a length of 2.3

and a width of 3.6 has an area of 8.28.

If I just simply continue to the next breakpoint.

We're going to see that in our terminal.

String English explanation is going to equal whatever the explain area function computes based on the

language that was passed in.

So the language that was passed in is English.

We expect the explained area function to return the following text.

That's exactly what it does.

The English explanation variable stores, whatever the explain area function returns when we pass any

value of English.

And here we're just printing it.

All right.

The point I wanted to drive home was that when your function isn't performing any sort of computation

or calculation, if it doesn't need to return anything of significance, then it needs to be void.

Void means the function doesn't return anything when it performs its task.

So when you're just printing something, there is really nothing to return.

But when your function is performing some sort of calculation, some sort of computation that is needed

to produce a final value, then you need to return that value from the function and then let whoever

is calling the function to handle that value as they see fit.

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