Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

{(Int)} is not identical to UInt8

Currently using beta 5 version of swift and There must have been a change to the += operator

func dealCards1() -> [Int] {
    for i in 0...25{
        comp1PlayDeck += shuffledDeck[i]
    }
    return comp1PlayDeck
}

this throws the '[(Int)]' is not identical to 'UInt8' I am not quite sure what changes were made however It is quite confusing.

like image 675
arcreigh Avatar asked Feb 03 '26 05:02

arcreigh


1 Answers

I suspect the error is the change in the += operator, it now only combines Arrays, not a value to an Array.

shuffledDeck[i] does not return an Array. Creating an array of it's value is a work-around.
Examples:

comp1PlayDeck += [shuffledDeck[i]]
comp1PlayDeck.append(shuffledDeck[i])

From the Beta5 release documents:
"• The += operator on arrays only concatenates arrays, it does not append an element. This ! resolves ambiguity working with Any, AnyObject and related types. (17151420)!"

like image 176
zaph Avatar answered Feb 06 '26 06:02

zaph