M
matt
Well, maybe not blocks with blocks but blocks with yield? although
right now, I only have a fix for procs with blocks and not blocks with
blocks via blocks with yield when a proc block is not in stock...
class Proc
alias __proc_block_call call
alias __proc_block_indexer []
def call(*args, &block)
__proc_block_call(*(block.nil? ? args : args << block))
end
def [](*args, &block)
__proc_block_indexer(*(block.nil? ? args : args << block))
end
end
-----
usage
prc = Proc.new {|arg, proc_block|
p arg
proc_block[arg]
}
prc.call("Foo") {|*what|
puts "Got #{what.length} whats -- #{what.inspect}"
}
produces:
"Foo"
Got 1 whats -- ["Foo"]
- also - it looks like the indexer function cannot take a block (parse
error) - why?
right now, I only have a fix for procs with blocks and not blocks with
blocks via blocks with yield when a proc block is not in stock...
class Proc
alias __proc_block_call call
alias __proc_block_indexer []
def call(*args, &block)
__proc_block_call(*(block.nil? ? args : args << block))
end
def [](*args, &block)
__proc_block_indexer(*(block.nil? ? args : args << block))
end
end
-----
usage
prc = Proc.new {|arg, proc_block|
p arg
proc_block[arg]
}
prc.call("Foo") {|*what|
puts "Got #{what.length} whats -- #{what.inspect}"
}
produces:
"Foo"
Got 1 whats -- ["Foo"]
- also - it looks like the indexer function cannot take a block (parse
error) - why?