- 40
- 248 209
Dave Leeds
เข้าร่วมเมื่อ 18 ก.ย. 2022
What are all of those Kotlin function types for?
Kotlin's got a surprising number of function types - what are they used for? In this video, we'll look at the range of different function types - from regular function types to KCallable, KFunction, KProperty, the Function interface, and more - and get a grip on when we might want to use each one.
✨ New to Kotlin? Start your journey here: typealias.com/start/
... or pick up the new Leanpub Edition for offline access and more! book.typealias.com/
🚀 Get the inside scoop on everything I'm working on - join my new email newsletter!
Sign up here: newsletter.typealias.com/
📚 Chapters
00:00 Kinds of Functions
01:58 Regular Function Types
02:48 The Function and FunctionN Interfaces
05:55 KFunction and Friends
08:50 Things to Keep in Mind
10:01 Wrap-up
✨ New to Kotlin? Start your journey here: typealias.com/start/
... or pick up the new Leanpub Edition for offline access and more! book.typealias.com/
🚀 Get the inside scoop on everything I'm working on - join my new email newsletter!
Sign up here: newsletter.typealias.com/
📚 Chapters
00:00 Kinds of Functions
01:58 Regular Function Types
02:48 The Function and FunctionN Interfaces
05:55 KFunction and Friends
08:50 Things to Keep in Mind
10:01 Wrap-up
มุมมอง: 3 156
วีดีโอ
Guards and Pattern Guards - TypeAlias Show Clip
มุมมอง 3.2K14 วันที่ผ่านมา
In this 9-minute clip from the TypeAlias Show Livestream, we look at the new pattern guards preview feature in Kotlin 2.1. ✨ New to Kotlin? Start your journey here: typealias.com/start/ ... or pick up the PDF Edition for offline access and more! shop.typealias.com/ 🚀 Get the inside scoop on everything I'm working on - join my new email newsletter! Sign up here: newsletter.typealias.com/ 🎞️ Watc...
Immutable and Persistent Lists - TypeAlias Show Clip
มุมมอง 2.5Kหลายเดือนก่อน
In this 12-minute clip from the TypeAlias Show Livestream, we look at the kotlinx.collections.immutable library. ✨ New to Kotlin? Start your journey here: typealias.com/start/ ... or pick up the PDF Edition for offline access and more! shop.typealias.com/ 🚀 Get the inside scoop on everything I'm working on - join my new email newsletter! Sign up here: newsletter.typealias.com/ 🎞️ Watch the full...
Anonymous Functions Aren't Lambdas
มุมมอง 4.4K2 หลายเดือนก่อน
Rarely spotted in the wild, Kotlin's anonymous functions blend some features of named functions with some features of lambdas. In this video, we'll check out what anonymous functions are and when we might want to use them. ✨ New to Kotlin? Start your journey here: typealias.com/start/ ... or pick up the new Leanpub Edition for offline access and more! book.typealias.com/ 🚀 Get the inside scoop ...
Fun with Function Types in Kotlin
มุมมอง 4.2K2 หลายเดือนก่อน
Let's look at the different kinds of function types in Kotlin, and see how we can call regular functions - and even property setters - as if they were extension functions! In this video, we'll examine standard function types, extension function types, bound references, and property references - and we'll pick up some fun tricks along the way! ✨ New to Kotlin? Start your journey here: typealias....
Subtyping Composables - TypeAlias Show Clip
มุมมอง 3.2K2 หลายเดือนก่อน
"If you want to create a design system in Compose where we use a slot API that doesn't allow any composable but only allows specific ones, how would you do that?" Here's one idea that worked for me, and I'd love to hear your thoughts about it! ✨ New to Kotlin? Start your journey here: typealias.com/start/ ... or pick up the new Leanpub Edition for offline access and more! book.typealias.com/ 🚀 ...
Applying the Builder Pattern in Kotlin
มุมมอง 5K3 หลายเดือนก่อน
The Builder design pattern enables us to construct complex objects in multiple steps. But how much of it is relevant for a modern programming language like Kotlin? In this video, we'll see a traditional version of the Builder Pattern, and then we'll see how we can improve upon it with Kotlin's language and library features. ✨ New to Kotlin? Start your journey here: typealias.com/start/ ... or p...
Applying the Factory Method and Abstract Factory Patterns in Kotlin
มุมมอง 6K3 หลายเดือนก่อน
Make object creation more flexible with the Factory Method and Abstract Factory design patterns! Today, we'll look at code that could benefit from these patterns, we'll apply a traditional version of them from the classic Gang of Four Design Patterns book, and then we'll see how we can modernize them with Kotlin's language features. ✨ New to Kotlin? Start your journey here: typealias.com/start/...
Applying the State Pattern in Kotlin
มุมมอง 8K4 หลายเดือนก่อน
When our objects behave differently in different states, then it can be helpful to apply the State Pattern. Today, we'll look at code that could benefit from the State Pattern, we'll apply a traditional State Pattern from the classic Gang of Four Design Patterns book, and then we'll see how we can modernize it and reduce boilerplate by using some of Kotlin's language features. ✨ New to Kotlin? ...
Applying the Decorator Pattern in Kotlin
มุมมอง 6K5 หลายเดือนก่อน
The Decorator Pattern allows us to augment the behavior of an object - without the object itself knowing about it! In this video, we'll start with code that could benefit from this pattern. Then we'll apply the Decorator Pattern using the classic approach as outlined in the original Gang of Four book. Finally, we'll modernize the pattern using some of Kotlin's language features. ✨ New to Kotlin...
Applying the Strategy Pattern in Kotlin
มุมมอง 9K5 หลายเดือนก่อน
Applying the Strategy Pattern in Kotlin
Kotlin Code Reuse: Composing like you're Inheriting
มุมมอง 12K6 หลายเดือนก่อน
Kotlin Code Reuse: Composing like you're Inheriting
7 Features in Kotlin's Standard Library that You Might Have Overlooked
มุมมอง 8K6 หลายเดือนก่อน
7 Features in Kotlin's Standard Library that You Might Have Overlooked
Inline Functions: inline, crossinline, and noinline
มุมมอง 7K9 หลายเดือนก่อน
Inline Functions: inline, crossinline, and noinline
Type Projections... and why they work!
มุมมอง 4.2K10 หลายเดือนก่อน
Type Projections... and why they work!
Dave, I found your channel recently and am already a big fan. I was curious to see you don't use code completion/autocomplete in IntelliJ, is that on purpose?
hey dave , couldn;t we have just handled the special request.amount condition inside the RefundRequest branch itself ? fun receive(request: Request) { when (request) { is OrderRequest -> Warehouse.fulfillOrder(request) is RefundRequest -> { if (request.amount < 10) { println("Automatically refunded") } else { Warehouse.fulfillRefund(request) } } is SupportRequest -> HelpDesk.handle(request) } } Are there are pros and cons here . I didn't fully grasp the need of the guard conditions
This is gold! Best video I've seen about coroutines.
Besides all these syntactic sugar it's simple OOP: an abstract User class with some concrete implementations
Facts
Hi Dave, kind of a weird question but my friend and I found your website by chance. And we stumbled upon the Turkish translation (named as Turki) of the first chapter of Dave Leeds on Kotlin. Its translation is both amazingly cool and funny as hell. Its translation has heavy Ottoman era word usage, and we have been trying to figure out who or what translated it? Is it AI, if so which AI, or is it a legendary person who knows Ottoman Turkish? Would be great if you can address our curiosity. It's really great. I don't think we have ever seen such a good use of Ottoman Turkish in a programming course material :)
Hey Mustafa! Wow, that's so funny! I'll have to ask the Turkish translator... part of the translator agreement is to not submit translations that have been run through a translation service or AI, except for occasional help with individual sentences. So maybe he's just an Ottoman era legend! Now it makes me want to add a Middle English translation of Chapter 1!
I just discovered your channel, this is some nice treasure for Kotlin devs out here, totally subscribed
Hey, thanks so much, Khaled! Glad you're here! 🎉
Surely something to reflect on! :)
Great video, as usual - golden standard of programming tutorials! Thank you 🙏
Very kind of you to say that, Sergey! Thanks so much!
Fantastic video! As a Flutter developer mainly, this was very easy and fun to understand and learn, thank you!
Thank you very much for your work, I accidentally came across your channel, found gold
You're most welcome, Stas! I'm glad you've been enjoying it!
Amazing content as always!
Nice video! Why did they choose this magic number 22 for the amount of parameters for a function?
I haven't seen any limits in the JVM that would make it a necessary choice, so I believe it's an arbitrary number. I suspect it was following after Scala's choice for the same thing, but @AntonArhipov might have more insight.
Great information Dave. Coming from java I always wondered about the "K" types. This is definitely helpful understanding the concept. Keep up the good work!
Thanks so much, Kedar! I'll keep at it!
I'm mindblown. Excellent content as always, I've learnt a lot from you
Great deep dive! ;)
Thanks, great video, as always! And amazing typing speed))
Thanks so much! Typing speed and accuracy are definitely aided by some automation and refined in post-production. I can't type that fast most of the time. 😅
I really enjoy the way you explain kotlin concepts. Hope you the best
Thanks so much, Fabio! Wishing the best to you, as well!
Thanks Dave! ❤
We enjoy your videos at my workplace, hope this channel starts getting some more momentum its kotlin gold! Algo will take off with it soon. Also, would be super cool to see some videos about the Kotlin Compiler, maybe something touching the FIR. KSP resources are also lacking to the quality of your videos, and we utilize it for some cool use cases. Appreciate the effort!!!
Hey, thanks so much! Glad to hear you all have been enjoying the videos. We're closing in on 10k subscribers soon! Good ideas about compiler/FIR, and KSP... I'll add those to my running list of video topic ideas. 👍
I love the language and your content. Thank you!
Thank you! Yes, it's a great language!
Just leaving a comment to support the channel, many thanks for your work!
Hey thanks so much for that, Simon! Glad you've been enjoying it!
What an explanation <3
Professor teaching mobile (therefore Kotlin) here - Absolutely fantastic metaphor and code examples. You really covered a ton of use cases for threads here, thank you so much for it! Linking this in our lecture notes!
Thank you so much, Paul! I'm glad you enjoyed it (and honored to be included in the lecture notes)!
One of the best
It’s increasing feature set without adding value. With ampersands I would be in, but the „if“ just looks strange. I’m not gonna use it, because it looks wrong.
thank god, a person who explains a complicated topic in plain english without an incomprehensible damn accent
Swift export looks promising
Hi, I saw that your website has all 20 chapters for free. Why buy the book in PDF? I would like to know if there are any other things in it besides the chapters that are advertised for free. Thanks
Hey Yaniv, thanks for asking! - With the PDF edition, you can read the book offline and mark it up with highlights and notes, by using your PDF software of choice. - It also includes a table of contents and an index, each of which links to the topics. - I also just recently finished updating all of the drawings and annotated code snippets in the PDF so that they're now using vector illustrations, so you can zoom in without losing any quality. - Once I get done with a few more small clean-up tasks, I'm expecting to also add a bonus Question-and-Answer section to each chapter, which would be exclusive to the PDF and print editions. Previously, the PDF edition also gave early access to new chapters, but of course, now that all 20 are complete, there aren't any more chapters to get early access to. 🙂 Hope that helps - let me know if you have any other questions!
@@typealias Thanks for your answer. I would like to know: If I buy the PDF now. Will I receive updates of it when you finish with the bonus questions?
Yes, whether you pick it up on Leanpub or on Fourthwall, you'll get access to the updates as I make them. With Leanpub, I only send email notifications about updates at particular milestones. With Fourthwall, you'll just get an email directly each time I push a new version. To get a feel for the frequency of updates I've made so far, you can see the release history on Leanpub here: leanpub.com/kotlin-illustrated - just scroll down to the "Release Notes" section. If you're on the fence about it, you could consider picking it up on Leanpub - they let you refund it within 60 days if it doesn't meet your expectations. So, if you're not seeing updates as quickly as you like, or if the upcoming Q&A sections aren't helpful for you, you could get a refund. Alternatively, you could just hold out another 4-6 weeks... I'm aiming to complete both the PDF and print editions within that timeframe. If you pick up the PDF on Leanpub at that point, you'd see the full set of bonus material and you could decide if you'd like to keep it.
You have an opt-out option on your TH-cam channel that automatically translates the video and chapter titles to the main language of the viewer. Technical terms loose all their meanings once translated.
Hey, thanks for mentioning that! Do you know the name of that option, or where I can find it? I just disabled the new Auto-Dub feature, but sounds like you might be talking about something else. Thanks!
Hi, I have no idea of specific name of the option and from what I know it isn't retroactive so the changes will only be visible on new videos
Okay, thanks. I'll poke around with this a little more and see if I can find it!
This is why I always set English as my display language
@@ArthurKhazbs then I will have the same issue with videos in my language, that's not a solution
How did you indent all arrows -> to right in when expression?
Hey, Asadullah - thanks for asking! Just open up your settings/preferences and go to Editor > Code Style > Kotlin > Wrapping and Braces. Then scroll down that list and look for "Align 'when' branches in columns". Once that's set, then when you use the auto-formatter, they'll line up like that. Let me know if you have any trouble finding it!
@@typealias Thank you, man. We all learn a lot from you. Keep up the good work.
Couldn't you add swift style guards to kotlin with something like `inline fun guard(check: Boolean, block: () -> Nothing) { if (!check) block() }`?
Then using said guard would be like `guard(order.placedByCustomerId == customer.id) { return }`, and you would be forced to short circuit since the lambda has a Nothing return type
that looks very neat! and is totally in-line with how it would be implemented if it were an official part of the language; as many built-in features are just library functions, making use of the existing powerful language features
Nice! 🎉 I'm going to play around with that and see what we can do with it! Thanks for sharing this.
Nice transition from wwf to www (sort of)
I like the idea of these guards. I've always been keen to short-circuiting to give a guaranteed state for the actual important logic or mutations and I can see the benefit of this experimental feature. What would be the timeline of it being brought to stable if it continues to move forward?
I haven't yet seen an announcement about when they expect pattern guards to become stable... and there are some strong opinions out there about which keyword to use for it, or whether to include them at all. So for now, I suspect they're focused on just collecting community feedback about it.
var me = "First"
me = "Second" //😅
@@h4m74ro me = "Third"
@@h4m74ro hahaha best cautionary tale against using `var` by default 😆
from simple to deep, a very concise but profound and informative explanation. Thank you a million times Deve! great job!
this is awesome, so well explained. thank you!
just tell me how you are doing kotlin better than kotlin ?
Community comments are great!
Thanks, Radek. Glad to know you liked that part - we'll plan to keep it as a regular segment! 👍
Need swift to kotlin
Maybe check out skip.tools/ ... I haven't used it myself, but it does Swift -> Kotlin, including the UI layer. A few guys from Skip were on the Kotlin podcast recently talking about it: th-cam.com/video/mig81rSWVqM/w-d-xo.html
@@typealias This is "Swift Multiplatform" but I need to use swift code in shared Kotlin module.
@@MonichGPT I remember someone at JetBrains saying that the goal is two-way export between Swift and Kotlin. Now they're working on Kotlin to Swift export, then they'll hopefully tackle the other way around. And the delay to this is perfectly understandable; they're trying to make two fundamentally different languages interop with each other. As much as Swift and Koltin look familiar, Swift is quite a beast compared to Kotlin, and functions a bit differently to Kotlin in the lower levels as well (e.g. GC vs. RC). So while Kotlin/Native runs basically at the same level as Swift code (and they both compile down to LLVM IR, and from there they look basically the same to LLVM), it's still quite the challenge to get these languages to "seamlessly" interop without much friction at the higher levels (APIs etc.).
As an experienced Android engineer. Should I learn multiplatform technical skills such as KMP, flutter, React Native. Which would be the best one.
I would go with KMP, you already know Android and Kotlin and the KMP stack seems to be growing fast.
@@delespai5592 Thank you bro, that makes sense.
I wish Kotlin would add support for dataarg (similar to vararg). It would make data classes more composable -- e.g. clone a data class with a few more fields without copying the full list of fields.
Why is it not here yet 😭
Yeah, haven't heard tooooo much about that yet! Maybe upvote and/or comment on the issue here: youtrack.jetbrains.com/issue/KT-8214/Allow-kind-of-vararg-but-for-data-class-parameter
It was mentioned in this talk (24 minute mark) that it will start in version 2.2: th-cam.com/video/tAGJ5zJXJ7w/w-d-xo.html
good
So cool!
this Video is so 🤯I'm a professional Java Developer, wich sitching currently to Kotlin, this is my 3th Video from you, and i love it. This is Nerd P**n
Hey, thanks so much, Christian! 😁 Glad you're enjoying the videos!
Thank you Dave. very clear explanation. more in-depth videos explaining coroutines please.
Thanks, Amir! I'm expecting to get to some more coroutines videos in the new year!
Do you plan to implement a Chain of Responsibility?
Yes, Chain of Responsibility is still on the list!
Masterfully explained. Loving this series.
Thanks so much! I'm glad you're enjoying it. More patterns videos coming soon.
Today I learned something new thankyou ❤