2

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))})
Ege Kuzubasioglu
  • 5,991
  • 12
  • 49
  • 85

1 Answers1

7

You have two ways to fix this error.

  1. Place a , between 52 and the lambda

    val cards : Array = Array(52, { i -> Card(i % 13, getSuit(i))})

  2. Place the lambda outside of the brackets

    val cards : Array = Array(52) { i -> Card(i % 13, getSuit(i))}

D3xter
  • 6,165
  • 1
  • 15
  • 13