Variables & Methods Flashcards
How do you define a variable?
variable_name = value
How do I reassign the value of:
variable_name = value
variable_name = other_value
What does snake case look like?
this_is_snake_case
What does camel case look like?
thisIsCamelCase
True or False: Variables can be written in both snake case and in camel case.
True
True or False: Variable names should start with a lowercase letter.
True
True or False: This is an acceptable name for a variable: 1st_place
False
Variable names should never start with a number.
True or False: This is an acceptable name for a variable: end
False
end is a reserved word in Ruby, meaning that it is used for other purposes and cannot be used as a variable name.
True or False: This is an acceptable name for a variable: danny’s_age
False
Apostrophes are not allowed in variable names.
name=”Richard”
How do I output the following using string interpolation?
“Hello, my name is Richard!”
puts “Hello, my name is #{name}!”
What is the difference between puts and print?
puts will output your code and will enter a new line. print will output your code but will not enter a new line.
How would you define a method named greeting?
def greeting #your code here end
How would you define a method named greeting with the argument of name?
def greeting(name) #your code here end
How do you invoke a method?
greeting(“Richard”)
True or False: A method can have multiple arguments.
True
Ex:
def greeting(name, date)
end