{"id":22763965,"url":"https://github.com/andyb129/31daysofkotlin","last_synced_at":"2025-04-10T02:28:20.365Z","repository":{"id":202475710,"uuid":"128268391","full_name":"andyb129/31DaysOfKotlin","owner":"andyb129","description":"A summary of all the Kotlin tips from Google's Android Developer #31DaysofKotlin on Twitter :computer:","archived":false,"fork":false,"pushed_at":"2018-04-05T22:44:20.000Z","size":4334,"stargazers_count":320,"open_issues_count":0,"forks_count":50,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-03T00:07:24.947Z","etag":null,"topics":["android","android-ktx","kotlin","tips"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andyb129.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-04-05T21:53:57.000Z","updated_at":"2025-01-04T07:21:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"edc64c31-bd91-419b-b382-8ecd69026d5b","html_url":"https://github.com/andyb129/31DaysOfKotlin","commit_stats":null,"previous_names":["andyb129/31daysofkotlin"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyb129%2F31DaysOfKotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyb129%2F31DaysOfKotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyb129%2F31DaysOfKotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyb129%2F31DaysOfKotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andyb129","download_url":"https://codeload.github.com/andyb129/31DaysOfKotlin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143928,"owners_count":21054845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-ktx","kotlin","tips"],"created_at":"2024-12-11T11:13:22.384Z","updated_at":"2025-04-10T02:28:20.346Z","avatar_url":"https://github.com/andyb129.png","language":"Kotlin","readme":"# 31 Days Of Kotlin \n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/android_tools.png\" height=\"100\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/kotlin_logo.png\" width=\"375\" height=\"95\" alt=\"kotlin logo\"/\u003e\n\u003c/p\u003e\n\nA summary of all the kotlin tips from Google's [Android Developer Twitter account](https://twitter.com/AndroidDev) with the hastag #31DaysofKotlin\n\nA Twitter Moment summary of all the tweets are here -\u003e [https://twitter.com/i/moments/980488782406303744](https://twitter.com/i/moments/980488782406303744) \n\n### TODO\n\n1. Add code samples in this repo for all 31 days \n2. Create an app for quick reference \n3. Create ref app in the Play Store\n\n### Contents\n\n##### [Day 1 - let, apply, with and run](#day1)\n##### [Day 2 - KTX view padding](#day2)\n##### [Day 3 - Parcelable](#day3)\n##### [Day 4 - Spans](#day4)\n##### [Day 5 - Lambdas](#day5)\n##### [Day 6 - Bundles](#day6)\n##### [Day 7 - Type safe builders](#day7)\n##### [Day 8 - KTX Content Values](#day8)\n##### [Day 9 - KTX iterators for ViewGroup \u0026 SparseArray](#day9)\n##### [Day 10 - Basic syntax](#day10)\n##### [Day 11 - Operator overload](#day11)\n##### [Day 12 - Sequence](#day12)\n##### [Day 13 - KTX Graphics](#day13)\n##### [Day 14 - Extension functions](#day14)\n##### [Day 15 - By](#day15)\n##### [Day 16 - KTX reified](#day16)\n##### [Day 17 - @JvmName](#day17)\n##### [Day 18 - inline](#day18)\n##### [Day 19 - require](#day19)\n##### [Day 20 - lateinit](#day20)\n##### [Day 21 - lazy](#day21)\n##### [Day 22 - sealed classes](#day22)\n##### [Day 23 - default parameters](#day23)\n##### [Day 24 - access modifiers](#day24)\n##### [Day 25 - data classes](#day25)\n##### [Day 26 - properties](#day26)\n##### [Day 27 - ranges](#day27)\n##### [Day 28 - when statement](#day28)\n##### [Day 29 - KTX destructuring](#day29)\n##### [Day 30 - string templates](#day30)\n##### [Day 31 - elvis operator](#day31)\n\n----\n\n\u003ca name=\"day1\"\u003e\u003c/a\u003e\n\n#### Day 1 - let, apply, with and run\n\nLet’s run with some standard Kotlin functions! Short and powerful, `let`, `apply`, `with` and `run` all have a receiver (this), may have an argument (it) and may have a return value. See the differences\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day1a.png\" width=\"512\" height=\"287\" alt=\"day1a\"/\u003e\n\u003cbr\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day1b.png\" width=\"512\" height=\"287\" alt=\"day1b\"/\u003e\n\u003cbr\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day1c.png\" width=\"512\" height=\"287\" alt=\"day1c\"/\u003e\n\u003cbr\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day1d.png\" width=\"512\" height=\"287\" alt=\"day1d\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day2\"\u003e\u003c/a\u003e\n\n#### Day 2 - KTX view padding\n\nExtending existing APIs with default arguments usually makes everyone happy. Android KTX lets you set the padding on one side of a view using default parameters. \n\nA one line function that saves so much code!\n\nCode: [https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/view/View.kt#L117](https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/view/View.kt#L117)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day2.png\" width=\"512\" height=\"287\" alt=\"day2\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day3\"\u003e\u003c/a\u003e\n\n#### Day 3 - Parcelable\n\nLove the speed of Parcelable, but don’t like writing all that code? Say hello to Parcelize\n\nSpec: [https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md](https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day3.png\" width=\"512\" height=\"287\" alt=\"day3\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day4\"\u003e\u003c/a\u003e\n\n#### Day 4 - Spans\n\nPowerful but hard to use - that’s how the text styling Spans API feels. \nAndroid KTX adds extension functions for some of the most common spans and makes the API easier to use\n\nAndroid KTX: [https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/text/SpannableStringBuilder.kt](https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/text/SpannableStringBuilder.kt)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day4.png\" width=\"512\" height=\"287\" alt=\"day4\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day5\"\u003e\u003c/a\u003e\n\n#### Day 5 - Lambdas\n\nLambdas are sweet. With last parameter call syntax, you can cleanup callbacks, Callable, and Runnable.\n\nFor example, Android KTX sweetens `postDelayed` with a small wrapper.\n\nDocs: [https://kotlinlang.org/docs/reference/lambdas.html](https://kotlinlang.org/docs/reference/lambdas.html)\nAndroid KTX: [https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/os/Handler.kt#L38](https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/os/Handler.kt#L38)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day5.png\" width=\"512\" height=\"287\" alt=\"day5\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day6\"\u003e\u003c/a\u003e\n\n#### Day 6 - Bundles\n\nBundle up, and get ready for the concise bundle creator in Android KTX. No more calls to `putString`, `putInt`, or any of their 20 friends.\n\nOne call will make you a new bundle, and it’ll even handle Arrays!\n\nCode: [https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/os/Bundle.kt#L27](https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/os/Bundle.kt#L27)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day6.png\" width=\"512\" height=\"287\" alt=\"day6\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day7\"\u003e\u003c/a\u003e\n\n#### Day 7 - Type safe builders\n\n[1/4] Specifically terrific? Domain specific languages can be made by using type safe builders. They make for clean APIs; and you can build them yourself too.\n\nExtension Lambdas: https://kotlinlang.org/docs/reference/lambdas.html#function-literals-with-receiver\nType Safe Builders: https://kotlinlang.org/docs/reference/type-safe-builders.html\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day7.png\" width=\"512\" height=\"287\" alt=\"day7\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day8\"\u003e\u003c/a\u003e\n\n#### Day 8 - KTX Content Values\n\nCombine the power of Content Values with the brevity of Kotlin. Use the Android KTX Content Values creator and just pass a Pair\u003cStringKey, Value\u003e.\n\nAndroid KTX: [https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/content/ContentValues.kt#L21](https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/content/ContentValues.kt#L21)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day8.png\" width=\"512\" height=\"287\" alt=\"day8\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day9\"\u003e\u003c/a\u003e\n\n#### Day 9 - KTX iterators for ViewGroup \u0026 SparseArray\n\nIterators in interesting places? Android KTX adds iterators to ViewGroup and SparseArray\n\nTo define iterator extensions use the `operator` keyword. Foreach loops will use the extensions!\n\nDocs: [https://kotlinlang.org/docs/reference/control-flow.html#for-loops](https://kotlinlang.org/docs/reference/control-flow.html#for-loops)\nAndroid KTX: [https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/view/ViewGroup.kt#L66](https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/view/ViewGroup.kt#L66)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day9.png\" width=\"512\" height=\"287\" alt=\"day9\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day10\"\u003e\u003c/a\u003e\n\n#### Day 10 - Basic syntax\n\n[1/2] Utility methods for a class? Add them to the top level of the source file. In Java, they are compiled as static methods of that class. \n\nDoc: [https://kotlinlang.org/docs/reference/basic-syntax.html](https://kotlinlang.org/docs/reference/basic-syntax.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day10.png\" width=\"512\" height=\"287\" alt=\"day10\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day11\"\u003e\u003c/a\u003e\n\n#### Day 11 - Operator overload\n\nWrite Kotlin (time * 2) faster with operator overloading. Objects like Path, Range or SpannableStrings naturally allow for operations like addition or subtraction. With Kotlin, you can implement your own operators\n\n[https://goo.gl/EGipGz](https://goo.gl/EGipGz)\n[https://goo.gl/iy8tZ9](https://goo.gl/iy8tZ9) \n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day11.png\" width=\"512\" height=\"287\" alt=\"day11\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day12\"\u003e\u003c/a\u003e\n\n#### Day 12 - Sequence\n\n[1/2] Sequences are lists that never existed. A Sequence is a cousin of Iterator, lazily generating one value at a time. This matters when using map and filter - they’ll create Sequences instead of copying the list for every step!\n\nDocs: [https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/index.html](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/index.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day12.png\" width=\"512\" height=\"287\" alt=\"day12\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day13\"\u003e\u003c/a\u003e\n\n#### Day 13 - KTX Graphics\n\nIf you ever converted a Drawable to a Bitmap then you know how much boilerplate you need. \n\nAndroid KTX has a great set of functions to make your code more concise when working with classes from the graphics package:\n\n[https://github.com/android/android-ktx/tree/master/src/main/java/androidx/core/graphics/drawable](https://github.com/android/android-ktx/tree/master/src/main/java/androidx/core/graphics/drawable)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day13.png\" width=\"512\" height=\"287\" alt=\"day13\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day14\"\u003e\u003c/a\u003e\n\n#### Day 14 - Extension functions\n\n[1/2] No more Util classes! Extend the functionality of a class by using `extension functions`. Put the name of the class you’re extending before the name of the method you’re adding.\n\nDoc: [https://kotlinlang.org/docs/reference/extensions.html#extension-functions](https://kotlinlang.org/docs/reference/extensions.html#extension-functions)\n\nExample: [https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/net/Uri.kt#L28](https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/net/Uri.kt#L28)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day14.png\" width=\"512\" height=\"287\" alt=\"day14\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day15\"\u003e\u003c/a\u003e\n\n#### Day 15 - By\n\nDelegate your work to another class with `by`. Favor composition over inheritance with class delegation and reuse property accessor logic with delegator properties.\n\nDelegation: [https://kotlinlang.org/docs/reference/delegation.html](https://kotlinlang.org/docs/reference/delegation.html)\n\nDelegated properties: [http://kotlinlang.org/docs/reference/delegated-properties.html](http://kotlinlang.org/docs/reference/delegated-properties.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day15.png\" width=\"512\" height=\"287\" alt=\"day15\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day16\"\u003e\u003c/a\u003e\n\n#### Day 16 - KTX reified\n\nTo make the concept of reified concrete an example is in order: `Context.systemService()` in Android KTX uses reified to pass a \"real\" type via generics. No more passing classes to getSystemService! [https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/content/Context.kt#L37](https://github.com/android/android-ktx/blob/master/src/main/java/androidx/core/content/Context.kt#L37)\n\nDocs: [https://kotlinlang.org/docs/reference/inline-functions.html#reified-type-parameters](https://kotlinlang.org/docs/reference/inline-functions.html#reified-type-parameters)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day16.png\" width=\"512\" height=\"287\" alt=\"day16\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day17\"\u003e\u003c/a\u003e\n\n#### Day 17 - @JvmName\n\nUsing Kotlin and Java in the same project? Do you have classes with top-level functions or properties? \n\nBy default, the compiler generates the class name as “YourFileKt”. Change it by annotating the file with `@file:JvmName(“...“)`.\n\nDoc: [https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html#package-level-functions](https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html#package-level-functions)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day17a.png\" width=\"512\" height=\"287\" alt=\"day17a\"/\u003e\n\u003cbr\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day17b.png\" width=\"512\" height=\"287\" alt=\"day17b\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day18\"\u003e\u003c/a\u003e\n\n#### Day 18 - inline\n\nCan’t wait to use lambdas to make new APIs? \n\nGet in line. \n\nKotlin lets you specify a function as `inline` - which means calls will be replaced with the function body. Breathe and make lambda-based APIs with zero overhead.\n\nDocs: [https://kotlinlang.org/docs/reference/inline-functions.html](https://kotlinlang.org/docs/reference/inline-functions.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day18.png\" width=\"512\" height=\"287\" alt=\"day18\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day19\"\u003e\u003c/a\u003e\n\n#### Day 19 - require\n\n[1/2] Are your function arguments valid? Check before using them, with `require`. If they’re not valid an IllegalArgumentException is thrown.\n\nDoc: [https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/require.html](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/require.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day19.png\" width=\"512\" height=\"287\" alt=\"day19\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day20\"\u003e\u003c/a\u003e\n\n#### Day 20 - lateinit\n\nIn Android, onCreate or other callbacks initialize objects. In Kotlin non-null vals must be initialized. What to do?\n\nEnter `lateinit`. It's a promise: initialize me later! Use it to pinky-swear it will \"eventually\" be null safe\n\nDocs: [https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties-and-variables](https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties-and-variables) \n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day20.png\" width=\"512\" height=\"287\" alt=\"day20\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day21\"\u003e\u003c/a\u003e\n\n#### Day 21 - lazy\n\nIt’s good to be lazy! Defer the cost of expensive property initialization until they’re actually needed, by using `lazy`. The computed value is then saved and used for any future calls. \n\nLazy: [https://kotlinlang.org/docs/reference/delegated-properties.html#lazy](https://kotlinlang.org/docs/reference/delegated-properties.html#lazy)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day21.png\" width=\"512\" height=\"287\" alt=\"day21\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day22\"\u003e\u003c/a\u003e\n\n#### Day 22 - sealed classes\n\n[1/3] Kotlin sealed classes let you easily handle error data. When combined with LiveData you can use one LiveData to represent both the success path and the error path. Way better than using two variables. \n\nDocs: [https://kotlinlang.org/docs/reference/sealed-classes.html](https://kotlinlang.org/docs/reference/sealed-classes.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day22.png\" width=\"512\" height=\"287\" alt=\"day22\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day23\"\u003e\u003c/a\u003e\n\n#### Day 23 - default parameters\n\nIs the number of method overloads getting out of hand? Specify default parameter values in functions.  \n\nMake the code even more readable with named parameters.\n\nDoc:  [https://kotlinlang.org/docs/reference/functions.html#default-arguments](https://kotlinlang.org/docs/reference/functions.html#default-arguments)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day23.png\" width=\"512\" height=\"287\" alt=\"day23\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day24\"\u003e\u003c/a\u003e\n\n#### Day 24 - access modifiers\n\nIn Kotlin, everything is public by default! Well, almost. Kotlin has a rich set of visibility modifiers you can use as well: private, protected, internal. Each of them reduces the visibility in a different way. \n\nDocs: [https://kotlinlang.org/docs/reference/visibility-modifiers.html](https://kotlinlang.org/docs/reference/visibility-modifiers.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day24.png\" width=\"512\" height=\"287\" alt=\"day24\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day25\"\u003e\u003c/a\u003e\n\n#### Day 25 - data classes\n\nCreating classes with one role: to hold data? Mark them as “data” classes. The default implementation of equals() is generated (so are hashCode(), toString(), and copy()) and checks for structural equality.\n\nDocs: \n[https://kotlinlang.org/docs/reference/data-classes.html#data-classes](https://kotlinlang.org/docs/reference/data-classes.html#data-classes)\n[https://kotlinlang.org/docs/reference/equality.html](https://kotlinlang.org/docs/reference/equality.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day25.png\" width=\"512\" height=\"287\" alt=\"day25\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day26\"\u003e\u003c/a\u003e\n\n#### Day 26 - properties\n\nIn Kotlin, classes can have mutable and read-only properties, with getters and setters generated by default. You can also implement custom ones if required.\n\nDocs: [https://kotlinlang.org/docs/reference/properties.html](https://kotlinlang.org/docs/reference/properties.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day26.png\" width=\"512\" height=\"287\" alt=\"day26\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day27\"\u003e\u003c/a\u003e\n\n#### Day 27 - ranges\n\nFor loops get superpowers when used with two other Kotlin features: range expressions and destructuring. \n\nRanges: [https://kotlinlang.org/docs/reference/ranges.html](https://kotlinlang.org/docs/reference/ranges.html)\n\nDestructuring: [https://kotlinlang.org/docs/reference/multi-declarations.html#destructuring-declarations](https://kotlinlang.org/docs/reference/multi-declarations.html#destructuring-declarations)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day27.png\" width=\"512\" height=\"287\" alt=\"day27\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day28\"\u003e\u003c/a\u003e\n\n#### Day 28 - when statement\n\nA switch statement with superpowers? Kotlin’s `when` expression can match on just about anything. Literal values, enums, ranges of numbers. You can even call arbitrary functions!\n \nDocs: [https://kotlinlang.org/docs/reference/control-flow.html#when-expression](https://kotlinlang.org/docs/reference/control-flow.html#when-expression)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day28.png\" width=\"512\" height=\"287\" alt=\"day28\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day29\"\u003e\u003c/a\u003e\n\n#### Day 29 - KTX destructuring\n\nNow with prisms? Android KTX uses destructuring to assign the component values of a color. You can use destructuring in your classes, or extend existing classes to add destructuring. \n\nDocs: [https://kotlinlang.org/docs/reference/multi-declarations.html](https://kotlinlang.org/docs/reference/multi-declarations.html)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day29.png\" width=\"512\" height=\"287\" alt=\"day29\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day30\"\u003e\u003c/a\u003e\n\n#### Day 30 - string templates\n\nFormatting Strings? Refer to variables and expressions in string literals by putting `$` in front of the variable name. Evaluate expressions using `${expression}`.\n\nDocs: [https://kotlinlang.org/docs/reference/basic-types.html#string-templates](https://kotlinlang.org/docs/reference/basic-types.html#string-templates)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day30.png\" width=\"512\" height=\"287\" alt=\"day30\"/\u003e\n\u003c/p\u003e\n\n\u003ca name=\"day31\"\u003e\u003c/a\u003e\n\n#### Day 31 - elvis operator\n\nHandling nulls in style? Check out the elvis operator `?:`, to cut your “null-erplate”. It’s just a small bit of syntax sugar to replace nulls with a default value or even return! \n\nDocs: [https://kotlinlang.org/docs/reference/null-safety.html#elvis-operator](https://kotlinlang.org/docs/reference/null-safety.html#elvis-operator)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/andyb129/31DaysOfKotlin/blob/master/app/src/main/res/drawable/day31.png\" width=\"512\" height=\"287\" alt=\"day31\"/\u003e\n\u003c/p\u003e\n\n\n### Thanks\n\nThanks to the Google Android Developer team for putting together this cool series of Kotlin info! :smile:\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyb129%2F31daysofkotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyb129%2F31daysofkotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyb129%2F31daysofkotlin/lists"}