{id: conditionals}
{id: comparison-operators} {i: ==} {i: <} {i: <=} {i: >} {i: >=}
- ==, <, > <=, >=
{id: spaceship-operator} {i: <=>}
- Spaceship operator <=> returns -1, 0, or 1
{id: if} {i: if} {i: else} {i: end}
{id: elsif} {i: elsif}
{id: unless} {i: unless}
- ameba: [C] Style/UnlessElse: Favour if over unless with else
{id: suffix-if} {i: if}
{id: suffix-unless} {i: unless}
{id: logical-operators}
&&
||
!
{id: truth-table}
{id: case} {i: case} {i: switch} {i: when}
- You cannot have the same value in
when
twice (Crystal protects you from such mistake)
{id: case-of-types}
{id: default-value} {i:||} {i: ?:}
{id: exercise-number-guessing-game-0}
Level 0
- Create a file called
number_guessing_game_0.cr
- Using the random module the computer "thinks" about a whole number between 1 and 20.
- The user has to guess the number. After the user types in the guess the computer tells if this was bigger or smaller than the number it generated, or if it was the same.
- The game ends after just one guess.
Level 1-
- Other levels in the next chapter.
{id: solution-number-guessing-game-0}