Hi, I got this piece of code: ``` val nested = lis...
# getting-started
a
Hi, I got this piece of code:
Copy code
val nested = listOf(listOf(12), listOf(12))
    val (one, two) = nested
    println("$one, $two")
That throws IOFB exception, I do not understand why
r
It works without a problem for me
s
same
is IOFB supposed to be
IndexOutOfBounds
exception? I’ve never seen anyone abbreviate it like that
a
Oh wrong code sorry
val nested = listOf(listOf(12))
replace it
s
?
I feel like you just answered your own question
a
@Shawn Well I kinda adopted calling exceptions in their abbreviation
r
If
nested
has only one element, what do you expect to happen when you destructure it into two?
👆 2
a
🤔 Welp
k
Coincidentally someone asked something very relevant in #general
k
Related to that, can you only destructure 5 elements from a list or is it implemented differently than
componentN()
?
k
You can implement as many of them as you want but the stdlib happens to stop at 5.
I'll admit I've implemented the 6th one a couple of times, even though destructing really starts to look messy.