0

Why cant i do something like that ?

var a=[[1, 0], [0, 1]]

or at least

var a: Array<Array<Int>> = [[1, 0], [0, 1]]

is it just impossible to do in kotlin?

rafaelc
  • 57,686
  • 15
  • 58
  • 82
Ofek Ron
  • 8,354
  • 13
  • 55
  • 103
  • Actually that's a List in Python, not an array. So if you want the same in Kotlin you need to use `listOf(listOf(1, 0), listOf(0, 1))` - or `mutableListOf` in case you want a mutable structure – user2340612 May 29 '20 at 19:20

1 Answers1

1

Kotlin is different language and has different array initialization for example you could use arrayOf and also primitive method like intArrayOf for integers

arrayOf(intArrayOf(1,0), intArrayOf(0,1))
iklinac
  • 14,944
  • 4
  • 28
  • 30