This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Numeric | |
| >> 1 == 2 # => false | |
| >> 1 == 1 # => true | |
| >> 3 != 3 # => false | |
| >> 5 > 10 # => false | |
| >> 5 < 10 # => true | |
| >> 10 >= 5 # => true | |
| >> 10 >= 10 # => true | |
| >> 10 >= 15 # => false | |
| >> 10 <= 15 # => true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def eric_runs_around(amount) | |
| "Eric runs around with his shirt off yelling 'I am a pretty little girl!!!'. He just made #{amount} dollars." | |
| end | |
| def eric_says_no(amount) | |
| "Eric rejects the offer and walks away. #{amount} isn't enough money." | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if offer >= 1000 | |
| eric_runs_around(offer) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if offer >= 1000 | |
| eric_runs_around(offer) | |
| else | |
| eric_says_no(offer) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if offer >= 1000 | |
| eric_runs_around(offer) | |
| elsif offer < 0 | |
| puts "Offer can't be negative, silly!" | |
| else | |
| eric_says_no(offer) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if a == 1 | |
| puts "One" | |
| elsif a == 2 | |
| puts "Two" | |
| elsif a == 3 | |
| puts "Three" | |
| elsif a == 4 | |
| puts "Four" | |
| elsif a == 5 | |
| puts "Five" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case a | |
| when 1 | |
| "One" | |
| when 2 | |
| "Two" | |
| when 3 | |
| "Three" | |
| when 4 | |
| "Four" | |
| when 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case | |
| when offer >= 1000 | |
| eric_runs_around(offer) | |
| when offer < 0 | |
| puts "Offer can't be negative, silly!" | |
| else | |
| eric_says_no(offer) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Numeric Ranges | |
| for i in (1..10) do | |
| puts "Number is #{i}" | |
| end | |
| # A through Z (Alphabetic Range) | |
| for letter in "A".."Z" do | |
| puts letter | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Nested loops | |
| for x in (1..10) do | |
| for y in (1..10) do | |
| puts x * y | |
| end | |
| end | |
| # Nested loops with mixed data | |
| for x in (1..10) do | |
| for letter in "A".."Z" do |