3 ms·
> Who's going to say this looks like Ruby now? Challenge accepted. Here's how far I've got so far: $l=[nil,nil,nil,nil] TracePoint.trace(:call) do |tp
by burke 6y ago
> Who's going to say this looks like Ruby now?
Challenge accepted. Here's how far I've got so far:
$l=[nil,nil,nil,nil]
TracePoint.trace(:call) do |tp|
$l << tp.self
$l.shift
end
class Lol < BasicObject
def initialize(f)
@f = f
end
def method_missing(m, *a)
# puts $l[0].inspect
$l[0].send(m, @f, *a)
end
end
class BasicObject
def ►(&blk)
::Lol.new(self).instance_exec(&blk)
end
end
module FooBar
def self.foo(a)
if a < 0
a.► { bar -1 }
else
a.► { bar 1 }
end
end
def self.bar(a, b)
(a*b).► { puts }
end
end
FooBar.foo(4)
- stopachka 6y agoMasterful! Great job burke!
- sergeykish 6y agoFooBar = Module.new def FooBar.foo(a) a < 0 ? bar(a, -1) : bar(a, 1) end def FooBar.bar(a, b) self.puts [a, b].reduce &:* end