1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/golf_prelude.rb

29 lines
540 B
Ruby
Raw Normal View History

SCRIPT_LINES__={}
class Object
def method_missing m, *a, &b
r = /^#{m}/
t = (methods + private_methods).sort.find{|e|r=~e}
t ? __send__(t, *a, &b) : super
end
def self.const_missing c
r = /^#{c}/
t = constants.sort.find{|e|r=~e} and return const_get(t)
raise NameError, "uninitialized constant #{c}", caller(1)
end
def h(a='H', b='w', c='!')
puts "#{a}ello, #{b}orld#{c}"
end
def quine(src = $0)
SCRIPT_LINES__[src].join
end
end
class Integer
alias each times
include Enumerable
end