Method pointer : Method Reflection « Reflection « Ruby






Method pointer


s = "sample string"
replacements = { "a" => "i", "tring" => "ubstitution" }

replacements.collect(&s.method("gsub"))
# => ["simple string", "sample substitution"]

 








Related examples in the same category

1.query almost any object within Ruby for the methods that are defined within it
2.Sort all method from Object
3.Listing Methods Unique to an Object
4.Getting a Reference to a Method