Hi there,
Is there a clever way of doing something like this?
def foo(*args, &block : typeof(args) ->)
block.call(args)
end
puts foo(1, 2, 3) { |a,b,c| a+b+c }
I need to specify the type of the block before I can capture it, but the compiler tells me I can’t call typeof
here, and because I don’t know how many items the typle args
contains I don’t know what type the block should be, although if I understand correctly, then at this point the compiler does know.
The following works, but doesn’t allow me to capture the block of course:
def foo(*args, &)
yield args
end
puts foo(1, 2, 3) { |a,b,c| a+b+c }