Mega Code Archive

 
Categories / Ruby / Method
 

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