Showing posts with label method invocation. Show all posts
Showing posts with label method invocation. Show all posts

Wednesday, November 30, 2011

How to invoke method in ruby?

Guys,
         Do you aware about the method invocation in ruby using different ways?
 want to know? There are 3 different ways to invoke a method in ruby.

a) Using period operator
    eg. we have class called 'Car' and we need to access the method called 'car_detail'
    car = Car.new
    car.car_detail

b) Using .send method
    car = Car.new
    car.send(:car_detail)

c) Using .call method
    car = Car.new
    car.method(:car_detail).call

So, these are the three ways to invoke method in ruby.  Hope this post will help you.