Functions
Predefined functions are great.
Even better is that you can define your own function.
Before we go deeper, we need to realize that we already have one function, main.
The main function is the first function that gets executed when you click Run.
Now let's define a function: greet(name).
It will say hello to someone.
Steps:
- add a new function by clicking + on the left pane
- click on
fun1block and rename it togreet - click + to add a new parameter and type
name: String - add a new
Outputand type"Hello " + name - click
mainto go back to main function - add a new
Callblock and typegreet("Tom")
Run the program, it should display Hello Tom in the output.