Start with a running file
A program is a set of instructions written as text. The editor below contains a complete file. Select Run program and read the Output pane. If Run on edit is selected, changes run automatically. You can reset the example at any time.
Read the greeting
The two lines beginning with // are notes for the reader. Execution begins at fn main(). The braces enclose the work that main performs. Inside them, println! writes the text between the double quotes and finishes the line. The semicolon ends that instruction.
Change one thing
Replace World inside the quoted greeting with your name. Leave the quotes, parentheses, exclamation mark and semicolon where they are. Run again and compare the two greetings. Changing the text changes what your reader sees.
Let the computer calculate
Add println!(6 * 7); on a new line inside the braces. Blyx evaluates the multiplication before printing 42. Put double quotes around 6 * 7 and you will see the characters instead. The difference between a value and text describing a value will recur throughout the course.
Try the program
Expected output
Hello, World from Blyx!
Practice
Make the program print Hello, Blyx! on its first line and 42 on its second.
Hint
Keep both print calls inside main. Use quotes for the greeting and leave the multiplication unquoted.
Worked solution
Each println! adds one line. The arithmetic expression evaluates before the second call.
Find
println!("Hello, World from Blyx!");Replace with
println!("Hello, Blyx!");
println!(6 * 7);Output after the change
Hello, Blyx! 42