TLK TLK - 1 year ago 83
Ruby Question

What's the maximum length of a method name in ruby?

I'm using RubyMine which informs me that

unsubscribe_from_all_notifications too long for a method name. What's the max length?

Answer Source

RubyMine lies :-) Or at least does not mean that it is a limitation of Ruby interpreter.

looong_name = "a" * 10000; # => "aaaaaaaaa.....
a_class =
a_class.__send__(:define_method, looong_name) { :hello } # => :hello

puts a_class.instance_methods.inspect # you better not run this :-)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download