News for hackers. Stuff that matters.
Re:Why blocks make Ruby methods slower by _mikz on Friday February 27, 2015 @01:53PM (#9120578)
You can create that Proc from implicit block on demand by calling `Proc.new` without a block.
Re:Why blocks make Ruby methods slower by masklinn on Friday February 27, 2015 @02:05PM (#9120648)
At which point you eat the reification cost.

It's real easy to test too: just bench

  def a flag
    Proc.new if flag
    nil
  end
with the flag set to `true` or `false`. Note that the proc is never actually called or returned to a possible caller, the only difference is that one reifies the proc and the other one not.

You'll get roughly the same 5x difference (with `flag=false` being the fastest) as TFA notes.

Re:Why blocks make Ruby methods slower by _mikz on Friday February 27, 2015 @04:40PM (#9121529)
Yes. But only when you actually need it (for example to store/pass it).
Re:Why blocks make Ruby methods slower by stormbrew on Friday February 27, 2015 @05:37PM (#9121820)
Note that this was actually the original way to do so. The &block argument format was added later.