module Enumerable def each_n_times(n) each { |e| n.times { yield e } } endend%w{Hello Echo}.each_n_times(3) { |x| puts x }# Hello# Hello# Hello# Echo# Echo# Echo