Position-based destructuring is such a footgun that we updated our style guide to only allow using it with classes from the standard library (eg. Pair) since those are the only places where future safety is guaranteed. Name-based destructuring would be awesome.
Lack of name-based destructuring and nested destructuring are the main issues to solve in my opinion to make destructuring trully useful in Kotlin. Especially the lack of nested destructuing is more often the problem.
How do I make "Rate Us" and "Send App" in Kotlin language?... I did it in many ways but it doesn't go directly to Google Play Store.... I need help guys!... Right code in fragment... I hope many of you did it if you are app developers by Kotlin
Position based structures (as anonymous pairs, or lists) are root of many hard to find bugs. I think that this has very limited valid usecases that would not become a maintenance hell. It was one of main plagues that used to drive me crazy about php codebases ~8 years ago.
The intro made me remember the philosophy 101 paper about Mario where "I believe" in "I believe it was Kant that said..." was crossed out. Quote on Quote "Horrible opening"
Would be really nice if you could use destructuring declarations with already existing variables, like if you already had var x,y and want to simply reassign them by some Pair
what about partial destructuring in your road map (that is closely linked to named destructuring) ? Based on your data class Person example, something like val (name, *restofproperties) = person? Is it something Kotlin is looking at ? This is so much helpful in languages like Typescript for example ( spread operator )
i use the `with` operator as it essentially gives you named destructuring in its scope and allows function calls: val anon = object { val lol = "lolVal" val wut = "wutVal" fun beCool() = "$lol, $wut!!" } //works w/pair, data class, etc with(anon) { println("lol -> $lol") println("wut -> $wut") println("funCall -> ${beCool()}") }
I was using pair based destructing, but from this video, Kotlin for Data science is even more attractive option compared to the most popular and easy to use python.
Often use with(data class){…} as a work around but as everyone else has said. They really need to implement name based. Positional destructuring is problematic.
Position-based destructuring is such a footgun that we updated our style guide to only allow using it with classes from the standard library (eg. Pair) since those are the only places where future safety is guaranteed.
Name-based destructuring would be awesome.
Great explanation, great to mention the caveats, good pace. Thank you!
Lack of name-based destructuring and nested destructuring are the main issues to solve in my opinion to make destructuring trully useful in Kotlin. Especially the lack of nested destructuing is more often the problem.
No name based destructuring is a big hole in ux.
Would also be great for more advanced pattern matching in `when`.
But overall I think destructuring isn't high priority. I've been aware it's there but never use it because it doesn't add much to readability
I was with you until nested destructuring. Nested destructuring always looks way more spaghetti 🍝 than just writing separate declarations
You've really come to be way more at ease on camera Sebastian, i've been following these on and off since a year ago and you've improved a lot :)
Very useful. I love how data classes implement component1 and component2.
Thanks again for making these videos.
Glad you like them!
Every Kotlin video with Sebastians face in the thumbnail is an Insta-click
Would be nice to have name-based destructuring syntax.
Thank you very much!
Nice video Seb 😍😍😍
How do I make "Rate Us" and "Send App" in Kotlin language?... I did it in many ways but it doesn't go directly to Google Play Store.... I need help guys!... Right code in fragment... I hope many of you did it if you are app developers by Kotlin
Position based structures (as anonymous pairs, or lists) are root of many hard to find bugs. I think that this has very limited valid usecases that would not become a maintenance hell. It was one of main plagues that used to drive me crazy about php codebases ~8 years ago.
The intro made me remember the philosophy 101 paper about Mario where "I believe" in "I believe it was Kant that said..." was crossed out.
Quote on Quote "Horrible opening"
Would be really nice if you could use destructuring declarations with already existing variables, like if you already had var x,y and want to simply reassign them by some Pair
Thanks for making video really helpful
what about partial destructuring in your road map (that is closely linked to named destructuring) ? Based on your data class Person example, something like val (name, *restofproperties) = person? Is it something Kotlin is looking at ? This is so much helpful in languages like Typescript for example ( spread operator )
I often use destructuring declarations, but I didn't know you can also use them on lists/arrays.
If we declare components for data class we will not face refactoring problem when we add a new member to our data class
Yes, see 4:10 in the video
The real fun begins with extension operator functions :D
i use the `with` operator as it essentially gives you named destructuring in its scope and allows function calls:
val anon = object {
val lol = "lolVal"
val wut = "wutVal"
fun beCool() = "$lol, $wut!!"
}
//works w/pair, data class, etc
with(anon) {
println("lol -> $lol")
println("wut -> $wut")
println("funCall -> ${beCool()}")
}
I was using pair based destructing, but from this video, Kotlin for Data science is even more attractive option compared to the most popular and easy to use python.
Super 👌
componentX functions are used for destructuring! didn't know that.
Often use with(data class){…} as a work around but as everyone else has said. They really need to implement name based. Positional destructuring is problematic.
💪💪👌
kotlin has new features that's i keep loving kotlin
but no company use it for server side using spring boot that's why not highly recommend
Nice (t-)shirt 🙈🙈
position based destructors are obsolete feature, I would never use them for their dangers.
o/
I don't know about that one chief.