Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* golf_prelude.rb: find words with underscore.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit 84e02c87184ba5e7adff6e53645e4414bdc57703 1 parent f610abc
Nobuyoshi Nakada nobu authored

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. +4 1 golf_prelude.rb
5 golf_prelude.rb
@@ -3,7 +3,10 @@
3 3 class Object
4 4 @@golf_hash = {}
5 5 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
7 10 t ? __send__(t, *a, &b) : super
8 11 end
9 12

0 comments on commit 84e02c8

Please sign in to comment.
Something went wrong with that request. Please try again.