Call String.instance_method to get a method pointer : Method Pointer « Method « Ruby
- Ruby
- Method
- Method Pointer
Call String.instance_method to get a method pointer
umeth = String.instance_method(:length)
m1 = umeth.bind("cat")
m1.call # 3
m2 = umeth.bind("caterpillar")
m2.call # 11
Related examples in the same category