środa, 24 sierpnia 2016

Extract method refactor and passing &block

Today I've tried to refactor code by extracting some part to a method. Spuriously it didn't work.

Problem was with passing block to a method. when you do that you pass block to method not the results.
In order to fix it we need to pass a block to find_each method by using &Proc.new as an extra argument. According to this article it is a fastest method.