top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can someone tell me a method to invoke an object in Ruby?

+1 vote
391 views
Can someone tell me a method to invoke an object in Ruby?
posted Jun 16, 2014 by Samardeep Acharya

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Here, I'm looking for the dot operator (or period operator), the Object#send method, or method(:foo).call

object = Object.new
puts object.object_id
 #=> 282660

puts object.send(:object_id)
 #=> 282660

puts object.method(:object_id).call # (Kudos to Ezra)
 #=> 282660
answer Jun 17, 2014 by Tapesh Kulkarni
...