Reputation: 6282
I think I messed up when I tried to write one line code in Kotlin, It seems like there is no problem but IntelliJ gives me this error here:
val cards : Array<Card> = Array(52 { i -> Card(i % 13, getSuit(i))})
Upvotes: 3
Views: 25886
Reputation: 6435
You have two ways to fix this error.
Place a ,
between 52
and the lambda
val cards : Array = Array(52, { i -> Card(i % 13, getSuit(i))})
Place the lambda outside of the brackets
val cards : Array = Array(52) { i -> Card(i % 13, getSuit(i))}
Upvotes: 7