Pattern: Redundant block call
Issue: -
This rule identifies the use of a &block
parameter and block.call
where yield
would do just as well. In MRI Ruby, block arguments are converted to Procs, which incurs a heap allocation.
# bad
def method(&block)
block.call
end
def another(&func)
func.call 1, 2, 3
end
# good
def method
yield
end
def another
yield 1, 2, 3
end