diesieben07
08/02/2017, 11:40 AMArray
constructor: Array(3) { index -> value }
, which initializes the array immediately, so you can have a non-null component type.horse_badorties
08/02/2017, 12:10 PMval squares = Array(8) { Array<Square>(8) { index -> Square(index, index)}}
index
refers to the "inner" index - is there a way to get the "outer" index, so I could do Square(iOuter, iInner)
?diesieben07
08/02/2017, 12:11 PMval squares = Array(8) { iOuter ->
Array<Square>(8) { iInner -> {
// produce square
}
}
horse_badorties
08/02/2017, 12:11 PMdiesieben07
08/02/2017, 12:11 PMdiesieben07
08/02/2017, 12:12 PMhorse_badorties
08/02/2017, 12:12 PMdiesieben07
08/02/2017, 12:13 PMArray(8, { index -> produceElement() })
is equivalent, but if the last parameter is a lambda, you can pass it outside the paretetheses.