Mercurial > repos > other > SevenLanguagesInSevenWeeks
annotate 1-Ruby/day1.rb @ 97:85a5e9a6ef5c
Add more notes on extracting Just/Maybe values
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 30 Jun 2019 16:09:44 +0100 |
parents | 3e4ea3d47880 |
children |
rev | line source |
---|---|
13 | 1 #! /usr/bin/env ruby |
2 | |
3 puts 'Hello, World' | |
4 puts 'Hello, Ruby'.index('Ruby') | |
5 i = 1 | |
6 | |
7 while i <= 10 | |
8 puts "This is sentence number #{i}" | |
9 i = i + 1 | |
10 end | |
11 | |
12 | |
13 randNum = rand(10) | |
14 guess = 11 | |
15 until guess == 'q' or guess.to_i == randNum | |
16 puts 'Guess the number (0-9) or "q" to quit' | |
17 guess = gets.strip | |
18 end | |
19 | |
20 puts "Well done! The number was #{randNum}" unless guess == 'q' |