Get pointer to a method in Fixnum : Method Pointer « Method « Ruby






Get pointer to a method in Fixnum


unbound_plus = Fixnum.instance_method("+")
plus_2 = unbound_plus.bind(2)   # Bind the method to the object 2
sum = plus_2.call(2)    # => 4
plus_3 = plus_2.unbind.bind(3)

 








Related examples in the same category

1.Use method from String class to map a method from String to a method pointer
2.Call String.instance_method to get a method pointer
3.Assign method pointer to another method