DEV Community

Shuichi Tamayose
Shuichi Tamayose

Posted on

Get the longest method name in Ruby

It can get the longest method name.

p ObjectSpace.each_object(Module).flat_map { |m| m.instance_methods + m.private_instance_methods }.uniq.max_by(&:size)
Enter fullscreen mode Exit fullscreen mode

I tried it in local machine. (ruby 2.4.3p205)

:fix_syck_default_key_in_requirements
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
ben profile image
Ben Halpern • Edited

I got the same thing on my local machine. In a project I got something pretty interesting and I'm now investigating 🤔

Collapse
 
siman profile image
Shuichi Tamayose

It may be getting a dynamically generated method name. In that case, can't see source code. 😢

Collapse
 
ben profile image
Ben Halpern

Yeah I'm sure it was, still an interesting one. Has me curious.

Collapse
 
gusga profile image
Gustavo Giménez

In rails 4.2.6 -> remove_active_admin_load_paths_from_rails_autoload_and_eager_load