Recall & Review
beginner
What does a method name ending with a
? usually indicate in Ruby?It indicates that the method returns a boolean value (true or false), often used for predicate methods that ask a question about an object.
Click to reveal answer
beginner
What is the purpose of a method name ending with a
! in Ruby?It signals that the method is "dangerous" or performs its action in a more surprising or destructive way, often modifying the object in place.
Click to reveal answer
intermediate
Can a method have both
? and ! suffixes in Ruby?No, Ruby does not allow method names to end with both
? and ! at the same time.Click to reveal answer
beginner
Why should you use
? suffix only for methods that return boolean values?Because it helps other programmers understand that the method answers a yes/no question, improving code readability and intention clarity.
Click to reveal answer
intermediate
Give an example of a Ruby method with a
! suffix and explain its behavior.Example:
upcase! modifies the string in place to uppercase letters, unlike upcase which returns a new string without changing the original.Click to reveal answer
What does a Ruby method ending with
? usually return?✗ Incorrect
Methods ending with
? are predicate methods that return true or false.What does the
! suffix in a Ruby method name usually warn about?✗ Incorrect
The
! suffix warns that the method may change the object or behave in a surprising way.Which of these is a valid Ruby method name?
✗ Incorrect
Methods can end with either
? or !, but not both or in combination.Why is it important to follow the
? and ! naming conventions in Ruby?✗ Incorrect
These suffixes help programmers understand what the method does at a glance.
What does the method
empty? typically check in Ruby?✗ Incorrect
empty? returns true if a string or collection has no content.Explain the difference between Ruby methods ending with
? and those ending with !.Think about how these suffixes help communicate what the method does.
You got /4 concepts.
Why is it helpful to use
? and ! suffixes in method names when writing Ruby code?Consider how naming conventions affect teamwork and maintenance.
You got /4 concepts.