What's the simplest way to get an array with three objects (Card
), one of which I already have? The other two should be randomly selected from the database.
My current approach looks like this:
[
@deck.cards[rand(@deck.cards.size)],
@deck.cards[rand(@deck.cards.size)],
@mycard
].sort_by {rand}
The problem I have right now is that sometimes @mycard
shows up twice in the array. How can this be avoided?