mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* golf_prelude.rb (Object.const_missing): Auto-complete constants.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3b83e10790
commit
f1ddd69d7b
2 changed files with 10 additions and 0 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Dec 28 10:06:54 2007 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* golf_prelude.rb (Object.const_missing): Auto-complete constants.
|
||||||
|
|
||||||
Fri Dec 28 01:55:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Dec 28 01:55:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* transcode.c (transcode_dispatch): allows transcoding from/to
|
* transcode.c (transcode_dispatch): allows transcoding from/to
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@ class Object
|
||||||
t ? __send__(t, *a, &b) : super
|
t ? __send__(t, *a, &b) : super
|
||||||
end
|
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='!')
|
def h(a='H', b='w', c='!')
|
||||||
puts "#{a}ello, #{b}orld#{c}"
|
puts "#{a}ello, #{b}orld#{c}"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue