Flow Control Flashcards
In Ruby, every expression evaluates as true when used in flow control, except for ___ and ___.
False and nil
conditional flow
When I am writing programs, I want my data to make the right decisions. I want my data to do the right thing it’s supposed to. In computer programming, this is called conditional flow
Conditionals
a fork (or many forks) i the road. My data approaches a conditional and the conditional then tells the data where to go based on some defined parameters.Formed using a combination of if statements and comparison and logical operators ( , <=, >=, ==, !=, &&, ||). Basic logical structures defined with the reserved words:
- if,
- else,
- elsif,
- end
boolean value
true or false, nothing else.
operands
expressions or values that an operator uses. In comparison, the expressions to the left and right of the operator are operands.
!=
The “ not equal to” operator. Anything to the left of the symbol is not equal to anything on the right.
>
“less than” symbol. Anything to the left of the symbol has a lower value than anything to the right
>
The “greater than” symbol. Anything to the left of the symbol has a higher value than anything to the right of the symbol.
When comparing strings, the comparison is _______________
character-by-character. Ruby moves from left-to-right in the strings looking for the first character that is different from its counterpart in the other string. Once it finds a character that differs, it compares that character with its counterpart and makes a decision based on that. If both strings are equal up to the length of the shorter string, then the shorter string is considered less than the longer string.
<=
“less than or equal to” symbol. Anything to the left of the symbol is less than or equal to anything on the right.
> =
“greater than or equal to” symbol. Anything to the left of the symbol is greater than the or equal to anything on the right.
&&
the “and” operator. Expressions to the left and the right of this operator have to be both true for the entire expression to be evaluated to true.
|
the “or” operator. Either the expression to the left has to be true, or the expression to the right has to be true for the entire expression to be evaluated to true.