Conditional Logic

Here we will study more about the CONTROL EXPRESSIONS in Ruby and provide some example that will help to create better code, conditional logic implies that we need to have some data and some rules in how to proceed, when the data is received, in order to obtain a desired output, here we do not nave tons of options like in other parts of Ruby but, the key here is not how many tools you have but how well you know how to use them, for more information follow the Ruby Iron-man Link below and  this 2nd-Link, and with no more delay, here are the tools of the trade.

” If ”   statement

” elsif “

“?”  –  “:”       Ternary operator

we can do the same with “true” and “false”

you can also use the logical results provided by Ruby


Modifier “if”

Modifier “unless”

Variable and Print “if”  (in one line)

“if” “| |”  (or)

“if”  “&&”  (and)

Example of: “if”, “elsif”,  “&&”, “| |”, “else” (single line)

“case”  “when”

“case” “-OR-“






Copyright 2017. All rights reserved.

Posted January 6, 2017 by Edmundo in category "Ruby