Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Intro to Ruby Reminders
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
You can’t perform that action at this time.