What does 'yield called out of block' mean in Ruby?

functional-programming, ruby

Solution

The problem is that the times method expects to get a block that it will yield control to. However you haven't passed a block to it. There are two ways to solve this. The first is to not use times:

mySet = (1..numOfCuts).map{ rand(seqLength) }

or else pass a block to it:

mySet = []
numOfCuts.times {mySet.push( rand(seqLength) )}

Problem

I'm new to Ruby, and I'm trying the following: ``` mySet = numOfCuts.times.map{ rand(seqLength) } ``` but I get the 'yield called out of block' error. I'm not sure what his means. BTW, this question is part of a more general question I asked here.

Original source

Related problems