Conditional Statements

36
1288 reads

March 5, 2013

Unless


Using Unless

34
1401 reads

March 5, 2013

Negation


Using Not Operator

39
1276 reads

March 5, 2013

Universal Constant


This is how we work with Universal Constants in Ruby

27
1297 reads

March 5, 2013

if unless Modifiers


You may recall the alternative syntax for while loops mentioned in Chapter 5. Instead of writing this< while tired do sleep end

37
1341 reads

March 5, 2013

if-then


When an if test and the code to be executed are placed on separate lines, the then keyword is optional.

35
1256 reads

March 5, 2013

More with if else if


More descriptive Example of if else if

40
1402 reads

March 5, 2013

Working with if else if


There will no doubt be occasions when you will need to take multiple different actions based on several alternative conditions.

27
1377 reads

March 5, 2013

if else alternative


Ruby also has a short-form notation for if..then..else in which a question mark ? replaces the if..then part and a colon : acts as else

Syntax
Test Condition ? if true do this : else do this

35
1249 reads

March 5, 2013

if else


A simple test like this has only one of two possible results. Either a bit of code is run or it isn’t, depending on whether the test evaluates to true or not.

29
1183 reads

March 5, 2013

Eccentricities of Boolean Operators


Be warned that Ruby’s Boolean operators can sometimes behave in a curious and unpredictable manner. For example:

puts( (not( 1==1 )) ) # This is ok