Bird
0
0

What does the Ruby method method(:name) return when called on an object?

easy📝 Conceptual Q1 of 15
Ruby - Blocks, Procs, and Lambdas
What does the Ruby method method(:name) return when called on an object?
AA Method object representing the method named :name
BThe result of calling the method named :name
CA symbol :name
DAn error if the method does not exist
Step-by-Step Solution
Solution:
  1. Step 1: Understand what method(:name) does

    This method returns a Method object that wraps the instance method called :name on the object.
  2. Step 2: Differentiate from calling the method

    Calling method(:name) does not execute the method but returns an object representing it.
  3. Final Answer:

    A Method object representing the method named :name -> Option A
  4. Quick Check:

    method(:name) = Method object [OK]
Quick Trick: method(:name) returns a Method object, not the method call result [OK]
Common Mistakes:
  • Confusing method(:name) with calling the method directly
  • Expecting a symbol instead of a Method object
  • Assuming it raises error always if method missing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes