Intro to Collection Builders in Kotlin

  Рет қаралды 4,945

Dave Leeds

Dave Leeds

Күн бұрын

Use Kotlin's Collection Builders to dynamically build out a collection's contents, without leaving it open to modifications. In this video, I'll show you what they are, and why you'd want to use them. And as a bonus, we'll even take a look at immutable collections!
New to Kotlin? Start learning here:
typealias.com/...

Пікірлер: 43
@thatdougsmith
@thatdougsmith Жыл бұрын
These are some of the best quality development videos I've ever seen! It's amazing they're free!
@typealias
@typealias Жыл бұрын
Thank you so much, Doug! I'm having lots of fun creating them! 🙂
@derekdevs
@derekdevs Жыл бұрын
I’m so glad I found your channel. Thank you for this quality content! As a new-to-Kotlin dev, I greatly appreciate it.
@typealias
@typealias Жыл бұрын
That's very kind of you to say, Derek! I'm so glad you're enjoying it!
@eonarma
@eonarma 5 ай бұрын
Thank you for the great content. I really love the way you explain things. I found you looking for coroutines information and I've looked at so many of your other videos. Great content. Keep yo the good work.
@somethingkindawierd
@somethingkindawierd Жыл бұрын
I love the animations on top of the code. Makes it super easy to follow the narration.
@typealias
@typealias Жыл бұрын
Thanks Jon! I know that animation in the wrong place or time can be more distracting than helpful, so I'm trying to be intentional about where I put it. I'm glad to hear that it worked well here! 🙂
@jesprotech
@jesprotech Жыл бұрын
This is probably the best Kotlin video I’ve ever seen so far! I don’t think I’ve used collection builders explicitly to be honest and this is pretty amazing! You made the video very simple and very clear! It’s also quite relatable with your example and the way you posed problems and solutions in such a short video! Keep up the good work! 👍
@typealias
@typealias Жыл бұрын
Wow, thank you so much - I'm really glad you enjoyed it! More videos are in the works! 🙂
@JasonYork
@JasonYork Жыл бұрын
Great video Dave! Well done.
@typealias
@typealias Жыл бұрын
Thanks so much Jason! Glad you liked it! 🙂
@prospernglazi7444
@prospernglazi7444 Жыл бұрын
This awesome, do you have a course? Your teaching style is right up my ally
@coalacorey
@coalacorey Жыл бұрын
His website (in the video description) is a valuable resource and his "Start Learning Kotlin" illustrated guide is structured like a course 👍
@typealias
@typealias Жыл бұрын
Hey Prosper, thanks so much! I'm actively working on a course, but it's still very early. I'd be happy to set you up with "super-early" access if you're interested. If you're on LinkedIn or Twitter, just send me a direct message (or you can email me... dave at typealias), and I'll get you set up.
@abhimanyu.n14
@abhimanyu.n14 Жыл бұрын
Hi Dave, Very useful video. Thanks :). Would love to see some content related to Kotlin DSL if possible. You make all the concepts seems so easy.
@typealias
@typealias Жыл бұрын
Thanks so much, Abhimanyu! Are you looking for content about how to _use_ a particular DSL, or about how to make your own DSLs?
@abhimanyu.n14
@abhimanyu.n14 Жыл бұрын
@@typealias As an Android dev, Gradle groovy was very complicated for me to understand. Hoping to understand Kotlin DSL better as there is a shift from Groovy to Kotlin as the recommendation now from Google. From basics, to advanced levels possible.
@typealias
@typealias Жыл бұрын
Ah, gotcha - thanks! Yes, the Gradle DSL is definitely easier to use with Kotlin Gradle Script than with Groovy, but there's is still quite a learning curve. I've got some research I'll need to do for that one! I'll get add it to the topic list.
@stephenmorse8207
@stephenmorse8207 Жыл бұрын
Thank you, I love your videos! I wish the immutable library was part of the standard library 😁
@typealias
@typealias Жыл бұрын
Yeah, I also wish they were in stdlib. While poking around with things, I did see that the Kotlin compiler itself does make use of the immutable collections library. Sounds like the Kotlin team has lots of big things planned for after the K2 compiler lands, so I'm hoping we'll see this library get closer to a version 1.0 after that. Especially since the prototype code they showed about Collection Literals at the KotlinConf keynote included PersistentSet. 😁
@Mike-er2ih
@Mike-er2ih Жыл бұрын
Already watched all available videos. Very HQ - thanks!
@typealias
@typealias Жыл бұрын
Thanks so much Mike! I'm glad you like them!
@sarathexp6328
@sarathexp6328 Жыл бұрын
as usual quality content ❤
@typealias
@typealias Жыл бұрын
Thank you so much, Sarath!
@ChrisAthanas
@ChrisAthanas 5 ай бұрын
Useful and clear
@typealias
@typealias 5 ай бұрын
Thanks so much, Chris! 🙂
@GB-nn2cx
@GB-nn2cx Жыл бұрын
Nice topic. Thanks
@typealias
@typealias Жыл бұрын
You're most welcome! I'm glad you liked it! 👍
@ulicqueldromal
@ulicqueldromal 10 ай бұрын
I used the immutable collections. I miss that compose multiplatform does not understand that they are stable
@typealias
@typealias 10 ай бұрын
Ah, thanks for pointing that out - I didn't realize there's an issue using them with Compose MP. I'll take a look when I get a chance!
@oharaandrew314
@oharaandrew314 Жыл бұрын
I wouldn't worry so much about the temporary list objects; the garbage collector is supposed to be very efficient at cleaning up short-lived immutable objects like those.
@typealias
@typealias Жыл бұрын
Yeah, and in most apps, performance is not as important as good structure and readability, anyway. At least in this case, I'd say we get both better performance _and_ better readability with buildList than with list concatenation. In any case, it'd be interesting to see some benchmarks on different Kotlin targets (JVM, Android, native, JS, WASM, etc.), for different sizes of lists to get a better understanding.
@oharaandrew314
@oharaandrew314 Жыл бұрын
@@typealias Yes, I won't dispute the improved readability at all!
@DiaryAnan
@DiaryAnan Жыл бұрын
His name is technically "dev lead of kotlin" 😂
@typealias
@typealias Жыл бұрын
Haha, "Dave Leeds" -> "Dev Lead" 😅 I see what you did there!
@TimSchraepen
@TimSchraepen Жыл бұрын
I continuously forget these exist. 😅
@typealias
@typealias Жыл бұрын
Haha, yeah! It's one of those things that, the more I used it, the more I realized I needed it. 🙂
@pavelpetrov5328
@pavelpetrov5328 Жыл бұрын
Make more vids :)
@typealias
@typealias Жыл бұрын
Haha, definitely will do! 😁
@avalagum7957
@avalagum7957 Жыл бұрын
IMO, contents.mapIndexedTo(result) { num, c -> "$num $c" } is more difficult to understand than contents.forEachIndexed { num, c -> result.add("$num $c") } Does mapIndexedTo have any advantage over forEachIndexed?
@typealias
@typealias Жыл бұрын
Hi Ava - As used here, there are no functional differences between those two approaches. The return types are different, though - mapIndexedTo() returns the list, whereas forEachIndexed() returns Unit. So, in situations where you might want to chain calls together, mapIndexedTo() might be a more natural fit. But since we aren't chaining calls in these examples, forEachIndexed() is a fine choice!
@avalagum7957
@avalagum7957 Жыл бұрын
@@typealias Got it. Thanks. I wonder why your IntelliJ didn't show a warning at that contents.mapIndexedTo line that the returned value is ignored. Mine sometimes does. Also notice that jdk 15 was used in this video. Was this video recorded 2.5 years ago?
@typealias
@typealias Жыл бұрын
For videos, I often set the inspection level to "Syntax", to minimize distractions. In this case, though, even with the inspection level set to "All Problems", I'm still not getting a warning. Maybe there's a particular inspection that isn't enabled here...? About the JDK - you're very observant! This was recorded more like 2.5 _weeks_ ago. I do actually have more recent JDK versions here, so I'll use those in future videos. 🙂
Easy SharedPreferences with Delegated Properties in Kotlin
21:18
Collections In Kotlin: Intro to List, Set, and Map
12:39
Will Tollefson
Рет қаралды 385
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
5 Fun Ways to Use Extension Functions in Kotlin
18:46
Dave Leeds
Рет қаралды 14 М.
Every Kind of Class in Kotlin
10:44
Dave Leeds
Рет қаралды 18 М.
Inline Functions: inline, crossinline, and noinline
11:59
Dave Leeds
Рет қаралды 8 М.
Coroutines: Concurrency in Kotlin
30:22
Dave Leeds
Рет қаралды 24 М.
Anonymous Functions Aren't Lambdas
9:08
Dave Leeds
Рет қаралды 4,6 М.
Everything you need to know about Kotlin 2.0 🟣
11:05
Stevdza-San
Рет қаралды 70 М.
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 90 М.
Write Once, Run Anywhere
6:06
Awesome
Рет қаралды 21 М.
Kotlin Collections Overview
12:27
Kotlin by JetBrains
Рет қаралды 16 М.
Collections and sequences - Kotlin Vocabulary
5:18
Android Developers
Рет қаралды 41 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН