Quiz

What is the assignment operator?

== is = -> = is the assignment operator. == is the equality operator (it checks for equality--more on that later!). is is an English word, and -> is a crude arrow, you goof.

Which of the following is in snake case?

a case that, like a wounded snake, drags its slow length along a_case_that_like_a_wounded_snake_drags_its_slow_length_along A_case_that_like_a_wounded_snake_drags_its_slow_length_along aCaseThatLikeAWoundedSnakeDragsItsSlowLengthAlong The second choice is correct. The third choice is capitalized, the fourth is in camel case (don't worry about what that means!), and the first employs typical English capitalization.
b = 7
a = true
b = "dog"
b = a
a = b

What is the value of b at the end of the above code snippet?

true 7 b "dog" b is last assigned to a when the value of a is true. Therefore the final value of b is true.
b = 7
a = true
b = "dog"
b = a
a = b

What is the value of a at the end of the above code snippet?

true 7 b "dog" a is last assigned to b when the value of b is true. Therefore the final value of a is true.
b = 7
a = true
b = "dog"
a = c

Why might the last line of the above code snippet cause an error?

c is nil. a cannot be reassigned. c is an invalid variable name. c is undefined. The fourth choice is correct. c is a valid variable name because it's in snake case and is not a Ruby keyword. a can be reassigned because any variable can be reassigned at any time. The value of c is not nil because c is undefined. A defined variable with a value of nil is different from a variable that is undefined, i.e., that is never assigned a value.

results matching ""

    No results matching ""