Skip to content

Commit

Permalink
* golf_prelude.rb (Object.const_missing): Auto-complete constants.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
knu committed Dec 28, 2007
1 parent 3b83e10 commit f1ddd69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Fri Dec 28 10:06:54 2007 Akinori MUSHA <[email protected]>

* golf_prelude.rb (Object.const_missing): Auto-complete constants.

Fri Dec 28 01:55:04 2007 Nobuyoshi Nakada <[email protected]>

* transcode.c (transcode_dispatch): allows transcoding from/to
Expand Down
6 changes: 6 additions & 0 deletions golf_prelude.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ def method_missing m, *a, &b
t ? __send__(t, *a, &b) : super
end

def self.const_missing c
r = /^#{c}/
t = constants.sort.find{|e|r=~e}
t ? const_get(t) : superclass.const_get(c)
end

def h(a='H', b='w', c='!')
puts "#{a}ello, #{b}orld#{c}"
end
Expand Down

0 comments on commit f1ddd69

Please sign in to comment.