Why blocks make Ruby methods slower
Wow, that is super interesting!<p>I think they buried the lede though. (Edit: not complaining! I like tech taught via a discovery narrative like they use here.) Given this:<p><pre><code>    def a(&block)
      yield
    end

    def b
      yield
    end
</code></pre>
Running `a {1+1}` is 4x slower than running `b {1+1}`. I didn't even know you <i>could</i> yield in a method without an explicit &block parameter. I'll guess I'll change my ways then, although I like having the block declared in the method signature so I know at a glance I can pass one. Too bad!<p>So I understand from the article that the slowness is because of extra memory allocation etc., but I still don't understand <i>why</i>. I mean, if both methods behave the same, what is the difference? Is it because declaring &block means my code in the method body can now "do stuff" with `block`, whereas in the implicit case I don't have a reference so I can't do any funny business but just yield? That would make sense.