TLK TLK - 4 months ago 11
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


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

Answer

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

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

puts a_class.instance_methods.inspect # you better not run this :-)
Comments