Bird
0
0

Identify the error in this Ruby method definition:

medium📝 Debug Q6 of 15
Ruby - Methods
Identify the error in this Ruby method definition:
def say_hello
  puts "Hello"
AMissing parentheses after method name
BMethod name cannot have underscore
CIncorrect use of puts inside method
DMissing end keyword to close method
Step-by-Step Solution
Solution:
  1. Step 1: Check method syntax

    Every method defined with def must be closed with end.
  2. Step 2: Identify missing part

    The code is missing the end keyword to close the method definition.
  3. Final Answer:

    Missing end keyword to close method -> Option D
  4. Quick Check:

    def ... end is required [OK]
Quick Trick: Always close methods with end keyword [OK]
Common Mistakes:
MISTAKES
  • Omitting end keyword
  • Thinking parentheses are mandatory
  • Misusing puts inside methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes