Bird
0
0

Identify the issue in this Ruby code:

medium📝 Debug Q6 of 15
Ruby - Ecosystem and Best Practices
Identify the issue in this Ruby code:
def greet_user
  puts "Hi"
end

greetUser()
AMethod greetUser is not defined because of missing parameters
BMissing return statement in the method
CIncorrect string syntax inside puts
DMethod name called does not match the defined method name due to case sensitivity
Step-by-Step Solution
Solution:
  1. Step 1: Check method definition

    The method is defined as greet_user using snake_case.
  2. Step 2: Check method call

    The method is called as greetUser(), which uses camelCase and differs in case.
  3. Step 3: Understand Ruby's case sensitivity

    Ruby treats method names as case-sensitive, so greetUser is undefined.
  4. Final Answer:

    Method name called does not match the defined method name due to case sensitivity -> Option D
  5. Quick Check:

    Method names are case-sensitive in Ruby [OK]
Quick Trick: Method names are case-sensitive; match exactly [OK]
Common Mistakes:
  • Assuming Ruby method names are case-insensitive
  • Thinking missing return causes error here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes