Kotlin tips
Kotlin Tips is a series of short videos where members of the Kotlin team show how to use Kotlin in a more efficient and idiomatic way to have more fun when writing code.
Subscribe to our YouTube channel to not miss new Kotlin Tips videos.
What happens when you add null + null
in Kotlin, and what does it return? Sebastian Aigner addresses this mystery in our latest quick tip. Along the way, he also shows why there's no reason to be scared of nullables:
Got a Kotlin collection that contains duplicates? Need a collection with only unique items? Let Sebastian Aigner show you how to remove duplicates from your lists, or turn them into sets in this Kotlin tip:
How come functions like repeat()
, map()
and filter()
accept suspending functions in their lambdas, even though their signatures aren't coroutines-aware? In this episode of Kotlin Tips Sebastian Aigner solves the riddle: it has something to do with the inline modifier:
Shadowing means having two declarations in a scope have the same name. So, how do you pick? In this episode of Kotlin Tips Sebastian Aigner shows you a simple Kotlin trick to call exactly the function that you need, using the power of fully qualified names:
Elvis has entered the building once more! Sebastian Aigner explains why the operator is named after the famous singer, and how you can use ?:
in Kotlin to return or throw. The magic behind the scenes? The Nothing type.
With destructuring declarations in Kotlin, you can create multiple variables from a single object, all at once. In this video Sebastian Aigner shows you a selection of things that can be destructured – pairs, lists, maps, and more. And what about your own objects? Kotlin's component functions provide an answer for those as well:
In Kotlin, you can override operators like addition and subtraction for your classes and supply your own logic. But what if you want to allow null values, both on their left and right sides? In this video, Sebastian Aigner answers this question:
Watch Sebastian Aigner give a quick overview of the measureTimedValue()
function, and learn how you can time your code:
In this video, Sebastian Aigner will demonstrate how to improve loops to make your code more readable, understandable, and concise:
In this episode, Kate Petrova shows three tips to help you work with Strings in Kotlin:
In this video, Sebastian Aigner will show how to add more logic to the Elvis operator, such as logging to the right part of the operator:
In this episode, Kate Petrova shows three tips to help you work with Kotlin Collections:
See the complete list of Kotlin Tips in our YouTube playlist
Learn how to write idiomatic Kotlin code for popular cases
Thanks for your feedback!