Because, as I mentioned earlier:
Optionalelement, so it will need to be unwrapped at some point before it can be used.
So something like:
var card = deck.randomElement() print("My card is \(card?.suit ?? "no card")")
By the way, this:
card = (String) (rndNum)
Is not the usual way to convert an
Int to a
String in Swift. Either of these would be better:
card = String(rndNum) card = "\(rndNum)"
The code you have technically turns
rndNum not into a
String but into a
(String), or a single-member tuple consisting of a
String. Although those get treated by the language as the equivalent of the single element’s type, they aren’t actually the same thing, as you can see if you check the type on your