Is there a way to get a list of instance method aliases somehow?
Array.instance_method_aliases # [‘size’, ‘map’, …]
If not, I think it would be a nice little bit of extra inspection I
could use in certain situations, like when I’m in irb and feeling too
lazy to look at the documentation.
Actually, this idea struck me when I tried to figure out just the “core”
methods for a given class and wanted to exclude the aliases. At the
time, I had to view the source code directly and count them. This
proved more difficult than I thought, because sometimes methods would
redefine functions with different names rather than use
rb_define_alias() in the source code.
To give you an example of what I mean, in array.c the Array#map function
is not declared using rb_define_alias(), but is simply mapped (no pun
intended) to a different function:
rb_define_method(rb_cArray, “collect”, rb_ary_collect, 0);
rb_define_method(rb_cArray, “map”, rb_ary_collect, 0);