Mercurial > repos > other > SevenLanguagesInSevenWeeks
diff 1-Ruby/logic.rb @ 12:e5b84cc7bc29
Update logic script re: "then" in "if else" statements
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 02 Jan 2017 21:16:35 +0000 |
parents | 700c167cad9f |
children |
line wrap: on
line diff
--- a/1-Ruby/logic.rb Mon Jan 02 21:13:00 2017 +0000 +++ b/1-Ruby/logic.rb Mon Jan 02 21:16:35 2017 +0000 @@ -31,4 +31,18 @@ puts "x equal 4" else puts "x not equals 4" -end \ No newline at end of file +end + +# "then" is optional, except in single line statement +if x == 4 then puts "x equal 4" end +if x == 4 then + puts "x equal 4" +end +if x == 4 + puts "x equal 4" +end +# The following line gives: +# logic.rb:…: syntax error, unexpected tIDENTIFIER, expecting keyword_then or ';' or '\n' +# if x == 4 puts "x equal 4" end +# +# if x == 4 puts "x equal 4" end \ No newline at end of file