Skip to content

Commit 84e02c8

Browse files
committed
* golf_prelude.rb: find words with underscore.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent f610abc commit 84e02c8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

golf_prelude.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
class Object
44
@@golf_hash = {}
55
def method_missing m, *a, &b
6-
t = @@golf_hash[[m,self.class]] ||= (methods + private_methods).sort.find{|e|/^#{m}/=~e}
6+
t = @@golf_hash.fetch(k = [m,self.class]) do
7+
r = /^#{m.to_s.gsub(/(?<=\w)(?=_)/, '\w*?')}/
8+
@@golf_hash[k] = (methods + private_methods).sort.find{|e|r=~e}
9+
end
710
t ? __send__(t, *a, &b) : super
811
end
912

0 commit comments

Comments
 (0)