-
Notifications
You must be signed in to change notification settings - Fork 0
Hello, World!
HENRYMARTIN5 edited this page Dec 28, 2021
·
1 revision
As usual, the Hello, World!
example is the simplest in the book. The code consists of this:
print("Hello, World!")
Now, let's take it a step further.
func greet(name)
print("Hello, " + name + "!")
end
print("What is your name?")
var name = input()
cls()
greet(name)
Whoa. What the heck does that do?
First, we define a function, greet(name)
, which takes one parameter, name
. The function then prints out "Hello, <name>
!"
Then, we ask the user for their name by assigning console input to a variable called name
.
Then, we clear the screen using cls()
, and greet the user with greet(name)
, passing in the name they typed into the console.