public
Description: investigations into nasty parenthesis operator overloading hacks
Homepage:
Clone URL: git://github.com/coderrr/parenthesis_hacks.git
coderrr (author)
Sun Nov 30 08:57:20 -0800 2008
commit  61f86b0c77997dc12db28390ee706f697549797e
tree    b0858643fddafdfd0d142fbe54f062c23a8e0fd3
parent  e57edcde2665f0060a1e5fad90f14e76d4ab49e0
parenthesis_hacks / lib / lambda.rb
100644 25 lines (20 sloc) 0.439 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'rubygems'
require 'ruby-debug'
Debugger.start
 
class Object
  alias_method :orig_method_missing, :method_missing
 
  def method_missing(m, *a, &b)
    begin
      l = eval(m.to_s, binding_n(1))
    rescue NameError
    else
      return l.call(*a) if l.respond_to? :call
    end
    orig_method_missing m, *a, &b
  end
end
 
def call_a_lambda_with_parenths(val)
  l = lambda {|v| p v }
  l(val)
end
 
call_a_lambda_with_parenths(6)