Mercurial > repos > other > SevenLanguagesInSevenWeeks
comparison 1-Ruby/blocks.rb @ 10:0374ae06729e
Start playing around with loop block definitions
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 02 Jan 2017 21:01:39 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:19fd9fd373d7 | 10:0374ae06729e |
---|---|
1 #! /usr/bin/env ruby | |
2 | |
3 x = 1 | |
4 | |
5 # Inline loops | |
6 x = x + 1 while x < 10 | |
7 puts x | |
8 | |
9 x = x - 1 until x == 1 | |
10 puts x | |
11 | |
12 # Conventional loops | |
13 while x < 10 | |
14 x = x + 1 | |
15 end | |
16 puts x | |
17 | |
18 until x == 1 | |
19 x = x - 1 | |
20 end | |
21 puts x |