From 4bb86b05e31ed9a780e18f59b22b2fc5652ee141 Mon Sep 17 00:00:00 2001
From: Richard Feldman
So far, so good!
Try typing this at the REPL prompt and pressing enter:
+Try typing this at the REPL prompt and pressing Enter:
"Hello, World!"
The REPL should cheerfully display the following:
-"Hello, World!" : Str +"Hello, World!" : Str # val1Congratulations! You've just written your first Roc code!
-When you entered the expression "Hello, World!"
into the REPL,
+
When you entered the expression "Hello, World!"
,
the REPL printed it back out. It also printed : Str
, because
-Str
is the expression's type. We'll talk about types later; for now, let's ignore
-the :
and whatever comes after it whenever the REPL prints them.
Str
is that expression's type. We'll talk about types later; for now, let's ignore
+the :
and whatever comes after it whenever we see them.
+The REPL also printed # val1
at the end of the line.
+That means from now on you can use the variable name val1
to refer
+to the "Hello, World!"
expression you just entered. This comes in handy
+when entering complicated expressions! Future sections of the tutorial will omit these labels, since they're
+just there as a convenience.
Still, while we're talking about them, let's try it out. Put this into the repl and press Enter:
+val1
+You should see the same "Hello, World!"
line as before.
You can also create your own names for expressions. Try entering these lines:
+greeting = "Hi"
+audience = "World"
+"\(greeting), \(audience)!"
+After entering that last one, you should see this output:
+"Hi, World!" : Str # val2 +This
+Next let's try putting in a more complicated expression:
1 + 1 @@ -64,7 +80,7 @@ be grouped. -1 : Num *Let's try calling a function:
+Let's try calling a function:
>> Str.concat "Hi " "there!"
"Hi there!" : Str