Learn Ruby: Blocks Explained

Here is the code example!

 def count(param)
    counter = 0
    while counter < param
        yield(counter)
        counter += 1
    end
end

count(5) { |n| puts "hello #{n}"}

Have a Question? Comment below!