What is a function it is basically lines of code which can be called multiple times within a script.
Functions can be created in two ways in the first the way we are specifying a function name followed
by parentheses and then inside Carol-Lee brackets are lines of code which will be processed.
Second option is to create function using keyboard function then is a name of your function.
And inside the brackets are lines of code which will be processed in this option.
We don't need to use parentheses after name of our function but we need to specify keyboard function.
Here is the example of how we can call function.
Hello from the script and it is really simple.
We just use the name of that function.
In my case.
Hello.
And you may notice that declaration of function Hello is that before the actual calling using function
name.
Hello.
This is all you need to remember.
Function can be called from some place only if declaration of that function Vasa before actual calling
we can of course use arguments when using functions.
Imagine function as some M.R. scrape inside your script here.
For example the calling function.
Hello.
And we are giving to that function one argument name.
Richard as a result function will print hello and value of first argument which is.
Richard we can also exit from function using the return keyboard.
If you use a written keyword we only exit from function not from a script.
And similarly with exit status we can ask for a function that returns status using dollar sign questionmark
year we would get a written status 11 in functions.
We can define local variables or does that means.
It means that local variable is visible only inside the function it was declared.
Here we can see the difference in example on the left side example we are reading the name Richard into
a variable name then we are calling a function.
Hello that argument.
Peter inside function well we assign into variable name Ververs previously value Richard value of argument
1 which is beat Peter after the function is finished.
We are a printing value of variable name which is Peter because we assign this value into variable name
in the function.
Hello.
On the right side example we are reading the name Richard into variable name then calling function a
hello with argument.
Peter an inside function.
Hello we are signing into a local variable name value of argument 1 which is Peter when the function
is finished we are printing Valo of variable name which is richer because we have change only a local
variable name not the global one variable stored value.
Richard.