Skip to content

Instantly share code, notes, and snippets.

@TatyCat
Last active September 9, 2015 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TatyCat/17453fe0218675aee492 to your computer and use it in GitHub Desktop.
Save TatyCat/17453fe0218675aee492 to your computer and use it in GitHub Desktop.
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