Review Ruby Flashcards
puts “put s”
- ‘prints’ the following on the screen
#
- hash, pound, octothorpe
- starts a comment line or used to disable a line of code
“…”
‘…’
- a string of text
- single quotes do things different. Can be used around a variable in a string, printing the output with single quotes showing
\+ - / * % < ><= >=
PEDMAS
PE(M&D) (A&S)
-plus
- minus
- slash (divide)
- asterisk (multiply)
- percent
(modulus - x divided by y with j remaining) The result of % is the j part , the remainder
{…}
- this is the format for inserting Ruby computations inside text strings. The result of the computation in the ‘printed’ string
Xxx_yyy
Underscore - puts an imaginary space between words in variable names
ex: carpool_capacity
4 vs 4.0
Integer vs floating point number
= (…)
= equals is used to give data (numbers, strings, etc. ) names
-sets a variable
==
- double equal tests whether two things have the same value
x=100 vs x = 100?
- it is bad form to leave out the spaces
variable
- any line of code where you set a name = (equal) to a value
ex. type_of_fish = 10
print vs puts
puts has a linefeed in it
Print does not
{} or %{} ?
Always use #{} to format strings
%{} is used when you want to apply strings multiple times
\n
%q{ - - - }
- escape sequence … linefeed
Print a multi line string
“””
- triple quotes works like a string, but you put as many lines of text as you want until you type
“”” again
note: use ‘’’ when you need a multiline string that contains #{} formatting, but you don’t want them to be processed yet or at all. Use “”” For all other multiline strings.