Add example of Ternary Operator (#25553)

pull/23118/head^2
Michael Kane 2018-12-01 12:41:31 -06:00 committed by Aditya
parent cd86f22c33
commit 25b6f1d924
1 changed files with 3 additions and 1 deletions

View File

@ -34,6 +34,8 @@ The above statement equal to the statement below
```
## Ternary Statement
A ternary statement is used as a short conditional statement. It is written as follows
*variable = condition ? true_result : false_result*
* ```ruby
game = "won"
fans = game == "won" ? "happy" : unhappy
@ -52,4 +54,4 @@ A case statement is similar to an if/elsif/else statement
else
puts "This is not an apple or an orange"
end
```
```