Last active
September 9, 2015 19:53
-
-
Save TatyCat/17453fe0218675aee492 to your computer and use it in GitHub Desktop.
Intro to Ruby Reminders
This file contains 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
Interpolated strings must be enclosed in double quotes. The Ruby interpreter will not search for interpolated values in a string if single quotes are used: | |
ex. p 'hello #{3}' | |
Notice the decimal used in the assignment of the rate variable. Decimals in programming are called Floats. | |
Notice the usage of the _ in the assignment of the principal variable. Ruby allows an _ to be used in numbers for better readability. Although an _ can be placed anywhere in a number, the best practice is to place them where a comma would normally be placed. (e.g. 1_000_000). | |
IF EXAMPLE STATEMENT | |
def can_buy_apple_with?(money) | |
if money > 5 | |
"have an apple" | |
end | |
end | |
can_buy_apple_with?(7) | |
&& || REMINDER | |
Ruby provides operators that add conditional logic to if statements. Specifically, the double ampersand && and double vertical bar || are logical operators that represent "and" and "or" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment