0

So I have this function remoteDrawCards, which takes an array of cards that is supposed to come from a remote computer, draw the same number of cards, and if they're the same allocate those cards to the remote player. I've taken out code that doesn't pertain to my issue and left a comment in it's place:

func remoteDrawCards(player: GKPlayer, remoteCards : [Card]) {
    //guard to check if the card count is the same remote and locally
    remoteCards.enumerated().map({(i, card) in
        // guard to check if each card is the same remote and locally            
        let playerStruct = players![player.playerID!]!
        // give the cards to the player
    })
    undoHistory.append(play: Play(action: .Draw(cards: remoteCards, player: player)))
}

Anyhow, I get an error on the remoteCards variable in the undoHistory.append line of code that says:

Expression type '[Card]' is ambiguous without more context

I don't understand why swift thinks this is ambiguous, and I'm not seeing any of the other times this has been asked that it occurs when a parameter is used.

Jon Thompson
  • 436
  • 4
  • 18

1 Answers1

0

What it is is that my .Draw was incorrectly formatted. My original issue was with a

for card in remoteCards{

}

giving the error, which I factored out before I asked this question with a .map(), but I thought the error came back when I used the variable in undoHistory. My proper use of .Draw is without the player, which is a variable in Play.

Jon Thompson
  • 436
  • 4
  • 18