diff --git a/README.md b/README.md index ae67285..8e6d8e7 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,24 @@ High-level programming language with effortless concurrency, automatic memory management, type safety and advanced error handling. +```dust +io.write_line("Guess the number.") + +secret_number = random.range(0..100) + +loop { + io.write_line("Input your guess.") + + input = io.read_line() + guess = int.parse(input) + + if guess < secret_number { + io.write_line("Too low!") + } else if guess > secret_number { + io.write_line("Too high!") + } else { + io.write_line("You win!") + break + } +} +``` diff --git a/examples/guessing_game.ds b/examples/guessing_game.ds index ef4404a..d99fa77 100644 --- a/examples/guessing_game.ds +++ b/examples/guessing_game.ds @@ -5,8 +5,8 @@ secret_number = int.random_range(0..100) loop { io.write_line("Input your guess.") - input = io.read_line() ? io.write_line("Failed to read input.") - guess = int.parse(input) ? io.write_line("Failed to parse input.") + input = io.read_line() + guess = int.parse(input) if guess < secret_number { io.write_line("Too low!")