methods - Ruby. How does the () operator work?

I recently came across some code using a method call consisting of the format object.(arg1, arg2) without seeing a good explanation of how it works. See this sample code:

class TestServiceObject
  def call
    'method'
  end
end

TestServiceObject.new.()
# => 'method'

What's the term for this kind of shorthand?

This question and all comments follow the "Attribution Required."

All Answers

Answers Loading...
Leave a Reply
You must be logged in to post a answer.
About the author