To me this makes perfect sense:
triple = dice.collect {|value| if (dice.count(value) >= 3)} ---> Syntax error
OR
triple = dice.collect {|value| dice.count(value) >= 3} ----> Array of true/false
I want the value of the number, not the true or falsity of dice.count(). I know there must be a simple way of doing this.
It sounds like you want
Array#select, notArray#collect(also known asArray#map).collect/mapwill take eachvalueand put the results of your block into an array. This is why you’re seeing an array of true/false.selectwill take eachvalue, and return it as a member of an array if the block evaluates totrue: