Deal action with a pack of cards I have a pack of cards and I am doing a 'deal' action. I am dealing n number of cards, for now to one player.

How can I DRY up the while and unless loops to have fewer lines?

def deal(number_of_players, number_of_cards_each)

 # 1..number_of_players

  players_cards_array=[]

  (1..number_of_cards_each).each do |a_card|

    added_card=false
    while added_card==false
      new_card = choose_card()
      unless @currently_dealt_cards.include?(new_card)
        players_cards_array &lt;&lt; new_card
        added_card= true
        @currently_dealt_cards &lt;&lt; new_card
      end 
    end 
  end 

  return players_cards_array

end
I agree with @mnhg: if you had the collection of cards beforehand, things would simplify dramatically:

players_cards = all_cards.sample(nplayers * ncards_each).each_slice(ncards_each).to_a