{"id":380822,"date":"2021-12-14T13:00:44","date_gmt":"2021-12-14T10:00:44","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/whats-new-in-kotlin-1-6-cloudsavvy-it\/"},"modified":"2021-12-14T13:00:44","modified_gmt":"2021-12-14T10:00:44","slug":"whats-new-in-kotlin-1-6-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/","title":{"rendered":"#What\u2019s New In Kotlin 1.6? \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a424b1f95ec8\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a424b1f95ec8\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#New_Native_Memory_Manager\" >New Native Memory Manager<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#Sealed_When_Statements\" >Sealed When Statements<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#Suspending_Type_Transformations\" >Suspending Type Transformations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#Code_Coverage_Scanner\" >Code Coverage Scanner<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#Standard_Library_Additions\" >Standard Library Additions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#readln_and_readlnOrNull\" >readln() and readlnOrNull()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#typeOf\" >typeOf()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#Collection_Builders\" >Collection Builders<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#Duration_Values\" >Duration Values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#More_Standard_Library_Changes\" >More Standard Library Changes<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#Other_Changes\" >Other Changes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-kotlin-1-6-cloudsavvy-it\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#What\u2019s New In Kotlin 1.6? \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<figure style=\"width: 1200px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage size-full wp-image-14905\" data-pagespeed-lazy-srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/2464a0d1.jpg?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/2464a0d1.jpg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/2464a0d1.jpg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Photo showing Kotlin logo overlay on computer code\" width=\"1200\" height=\"675\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-photo\/saint-petersburg-russia-july-4-2019-1449950858\">Trismegist san\/Shutterstock.com<\/a><\/span><\/figcaption><\/figure>\n<p>Kotlin 1.6 <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/blog.jetbrains.com\/kotlin\/2021\/11\/kotlin-1-6-0-is-released\">is out<\/a> with new features, an improved experimental memory manager, and an enhanced standard library. The additions help mature JetBrains\u2019 increasingly popular cross-platform and cross-discipline language.<\/p>\n<h2 id=\"new-native-memory-manager\"><span class=\"ez-toc-section\" id=\"New_Native_Memory_Manager\"><\/span>New Native Memory Manager<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Arguably the biggest change for the Kotlin ecosystem is the arrival of the new memory manager for Kotlin Native. While it\u2019s still labelled <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/blog.jetbrains.com\/kotlin\/2021\/08\/try-the-new-kotlin-native-memory-manager-development-preview\">as a developer preview<\/a>, the updated manager is representative of the direction Kotlin will take in the future.<\/p>\n<p>The revised design is better equipped to deal with the different compilation backends used to transform Kotlin into native platform code for iOS and Android. Sometimes the platforms require different optimizations for a specific operation. The current <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>roach imposes limitations on concurrency and can create memory leaks without special developer attention.<\/p>\n<p>The next generation memory manager addresses these shortcomings. It offers leak-free primitives for concurrent operations that are safe to use as-is. The changes also bring Native memory management into greater parity with the existing memory manager for JVM development.<\/p>\n<p>While the new system is available in Kotlin 1.6, it\u2019s not currently intended for production use. In some situations, performance could be reduced <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/blog.jetbrains.com\/kotlin\/2021\/08\/try-the-new-kotlin-native-memory-manager-development-preview\/\">by up to 5x<\/a> compared with the legacy memory manager. Development efforts are ongoing on a performant version that\u2019s ready for <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a> uptake.<\/p>\n<h2 id=\"sealed-when-statements\"><span class=\"ez-toc-section\" id=\"Sealed_When_Statements\"><\/span>Sealed When Statements<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Sealed <code>when<\/code> statements let you receive a compiler warning when you forget to handle a possible case. If you pass a sealed class, boolean type, or enum into a <code>when<\/code>, you\u2019ll normally want to take an explicit course of action for each possible input value:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"kotlin\">\n<pre class=\"de1\"><span class=\"kw1\">sealed<\/span> <span class=\"kw1\">class<\/span> Drivetrain <span class=\"br0\">{<\/span>\n    <span class=\"kw1\">data<\/span> <span class=\"kw1\">class<\/span> Electric<span class=\"br0\">(<\/span><span class=\"kw1\">val<\/span> Power<span class=\"sy0\">:<\/span> <span class=\"kw4\">Int<\/span><span class=\"br0\">)<\/span> <span class=\"sy0\">:<\/span> Drivetrain<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\n    <span class=\"kw1\">data<\/span> <span class=\"kw1\">class<\/span> Diesel<span class=\"br0\">(<\/span><span class=\"kw1\">val<\/span> Power<span class=\"sy0\">:<\/span> <span class=\"kw4\">Int<\/span><span class=\"br0\">)<\/span> <span class=\"sy0\">:<\/span> Drivetrain<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\n    <span class=\"kw1\">data<\/span> <span class=\"kw1\">class<\/span> Hybrid<span class=\"br0\">(<\/span><span class=\"kw1\">val<\/span> Diesel<span class=\"sy0\">:<\/span> Drivetrain, <span class=\"kw1\">val<\/span> Electric<span class=\"sy0\">:<\/span> Drivetrain<span class=\"br0\">)<\/span> <span class=\"sy0\">:<\/span> Drivetrain<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\n<span class=\"br0\">}<\/span>\n\u00a0\n<span class=\"kw1\">fun<\/span> getTotalPowerKwh<span class=\"br0\">(<\/span>drivetrain<span class=\"sy0\">:<\/span> DriveTrain<span class=\"br0\">)<\/span> <span class=\"sy0\">:<\/span> <span class=\"kw4\">Int<\/span> <span class=\"br0\">{<\/span>\n    <span class=\"kw1\">when<\/span> <span class=\"br0\">(<\/span>drivetrain<span class=\"br0\">)<\/span> <span class=\"br0\">{<\/span>\n        <span class=\"kw1\">is<\/span> Drivetrain.<span class=\"me1\">Diesel<\/span> <span class=\"sy0\">-&gt;<\/span> drivetrain.<span class=\"me1\">Diesel<\/span>.<span class=\"me1\">Power<\/span>\n        <span class=\"kw1\">is<\/span> Drivetrain.<span class=\"me1\">Electric<\/span> <span class=\"sy0\">-&gt;<\/span> drivetrain.<span class=\"me1\">Electric<\/span>.<span class=\"me1\">Power<\/span>\n    <span class=\"br0\">}<\/span>\n<span class=\"br0\">}<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>In the example above, the <code>Drivetrain<\/code> sealed class has three data classes within it. The <code>when<\/code> statement only handles two of them \u2013 if your code receives a hybrid drivetrain, an incorrect value will be returned.<\/p>\n<p>The Kotlin compiler will now alert you to this problem. In Kotlin 1.7, not exhaustively covering all the possibilities will result in a compilation error.<\/p>\n<h2 id=\"suspending-type-transformations\"><span class=\"ez-toc-section\" id=\"Suspending_Type_Transformations\"><\/span>Suspending Type Transformations<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Transformations from regular to suspending types have been stabilized via automatic compiler conversions. The compiler will create the conversion automatically when you pass a regular type expression into a context where a suspending type is expected.<\/p>\n<p>This enables code like the following:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"kotlin\">\n<pre class=\"de1\"><span class=\"kw1\">fun<\/span> createUser<span class=\"br0\">(<\/span>name<span class=\"sy0\">:<\/span> <span class=\"kw3\">String<\/span><span class=\"br0\">)<\/span> <span class=\"br0\">{<\/span>\n    <span class=\"co1\">\/\/ ...<\/span>\n<span class=\"br0\">}<\/span>\n\u00a0\nflow.<span class=\"me1\">collect<\/span><span class=\"br0\">(<\/span><span class=\"sy0\">::<\/span>createUser<span class=\"br0\">)<\/span>\n\u00a0\n<span class=\"kw1\">val<\/span> createUserFunction <span class=\"sy0\">=<\/span> <span class=\"sy0\">::<\/span>createUser\nflow.<span class=\"me1\">collect<\/span><span class=\"br0\">(<\/span>createUserFunction<span class=\"br0\">)<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>This code used to break on the second <code>flow.collect()<\/code> call. The <code>createUserFunction<\/code> variable refers to the regular function definition, not the suspension created by the first call. Kotlin will now handle this by creating a suspended version when the receiving context requires it.<\/p>\n<p>Suspending functions are also supported as supertypes now. This lets you pass classes that implement suspending functional types wherever a suspending function reference is currently supported.<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"kotlin\">\n<pre class=\"de1\"><span class=\"kw1\">class<\/span> ImplementsSuspendingFunctionalType <span class=\"sy0\">:<\/span> <span class=\"kw1\">suspend<\/span> <span class=\"br0\">(<\/span><span class=\"br0\">)<\/span> <span class=\"sy0\">-&gt;<\/span> <span class=\"kw4\">Unit<\/span> <span class=\"br0\">{<\/span>\n    <span class=\"kw1\">override<\/span> <span class=\"kw1\">suspend<\/span> <span class=\"kw1\">fun<\/span> invoke<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span> <span class=\"br0\">{<\/span> <span class=\"coMULTI\">\/* ... *\/<\/span> <span class=\"br0\">}<\/span>\n<span class=\"br0\">}<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>The <code>suspend () -&gt; Unit<\/code> interface is implemented in the same way as you can already use <code>() -&gt; Unit<\/code> for non-suspending types.<\/p>\n<h2 id=\"code-coverage-scanner\"><span class=\"ez-toc-section\" id=\"Code_Coverage_Scanner\"><\/span>Code Coverage Scanner<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Kotlin now has an official code coverage scanning tool. <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/Kotlin\/kotlinx-kover\">Kover<\/a> is a Gradle plugin which collects the coverage statistics of tests for Kotlin JVM, Multiplatform and mixed Java projects. It can generate reports in HTML and XML formats.<\/p>\n<p>Kover provides full compatibility with the Kotlin language and its Gradle toolchain. Although some third-party tools can already provide coverage scores, they exist outside the ecosystem and don\u2019t always have visibility into every task. Kover offers a fully integrated approach. Development is ongoing with this initial release labelled as experimental.<\/p>\n<p>To enable Kover, add the following lines to your top-level build file:<\/p>\n<pre>plugins {&#13;\n     id(\"org.jetbrains.kotlinx.kover\") version \"0.4.2\"&#13;\n}<\/pre>\n<p>Kover will now run as part of your Gradle builds.<\/p>\n<h2 id=\"standard-library-additions\"><span class=\"ez-toc-section\" id=\"Standard_Library_Additions\"><\/span>Standard Library Additions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There are a few noteworthy changes to the standard library, including the promotion of several beta functions to stable:<\/p>\n<h3 id=\"readln-and-readlnornull\"><span class=\"ez-toc-section\" id=\"readln_and_readlnOrNull\"><\/span>readln() and readlnOrNull()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>These two new functions read and return a line from the standard input stream. The former will throw if the EOF mark has been reached whereas the latter returns <code>null<\/code>.<\/p>\n<h3 id=\"typeof\"><span class=\"ez-toc-section\" id=\"typeOf\"><\/span>typeOf()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The <code>typeOf()<\/code> function lets you determine the actual type of a reified type, usually expressed as <code>T<\/code>, at runtime.<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"kotlin\">\n<pre class=\"de1\"><span class=\"kw1\">inline<\/span> <span class=\"kw1\">fun<\/span> <span class=\"sy0\">&lt;<\/span><span class=\"kw1\">reified<\/span> T<span class=\"sy0\">&gt;<\/span> getTypeString<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span> <span class=\"sy0\">:<\/span> <span class=\"kw3\">String<\/span> <span class=\"br0\">{<\/span>\n    <span class=\"kw1\">val<\/span> type <span class=\"sy0\">=<\/span> typeOf<span class=\"sy0\">&lt;<\/span>T<span class=\"sy0\">&gt;<\/span><span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\n    <span class=\"kw1\">return<\/span> type.<span class=\"me1\">toString<\/span><span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\n<span class=\"br0\">}<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 id=\"collection-builders\"><span class=\"ez-toc-section\" id=\"Collection_Builders\"><\/span>Collection Builders<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>New builder functions let you easily create collections from a set of different values. You can combine maps, lists, and sets into new collections using first-class functions:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"kotlin\">\n<pre class=\"de1\"><span class=\"kw1\">val<\/span> fruits <span class=\"sy0\">=<\/span> listOf<span class=\"br0\">(<\/span><span class=\"st0\">\"apple\"<\/span>, <span class=\"st0\">\"banana\"<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\n<span class=\"kw1\">val<\/span> veg <span class=\"sy0\">=<\/span> listOf<span class=\"br0\">(<\/span><span class=\"st0\">\"carrot\"<\/span>, <span class=\"st0\">\"cabbage\"<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\n\u00a0\n<span class=\"kw1\">val<\/span> groceries <span class=\"sy0\">=<\/span> buildList <span class=\"br0\">{<\/span>\n    add<span class=\"br0\">(<\/span><span class=\"st0\">\"milk\"<\/span><span class=\"br0\">)<\/span>\n    addAll<span class=\"br0\">(<\/span>fruits<span class=\"br0\">)<\/span>\n    addAll<span class=\"br0\">(<\/span>veg<span class=\"br0\">)<\/span>\n<span class=\"br0\">}<\/span>\n\u00a0\n<span class=\"co1\">\/\/ [\"milk\", \"apple\", \"banana\", \"carrot\", \"cabbage\"]<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 id=\"duration-values\"><span class=\"ez-toc-section\" id=\"Duration_Values\"><\/span>Duration Values<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The <code>Duration<\/code> class for representing time values has been promoted to stable. It provides an integrated type to store a time period duration in your code. The class has methods that facilitate easy conversions between units:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"kotlin\">\n<pre class=\"de1\"><span class=\"co1\">\/\/ Emits 1.0<\/span>\nprintln<span class=\"br0\">(<\/span><span class=\"nu0\">60<\/span>.<span class=\"me1\">toDuration<\/span><span class=\"br0\">(<\/span>DurationUnit.<span class=\"me1\">SECONDS<\/span><span class=\"br0\">)<\/span>.<span class=\"me1\">inMinutes<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 id=\"more-standard-library-changes\"><span class=\"ez-toc-section\" id=\"More_Standard_Library_Changes\"><\/span>More Standard Library Changes<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Integers have new <code>rotateLeft()<\/code> and <code>rotateRight()<\/code> functions. These rotate the number\u2019s binary representation by a specified number of bits in the indicated directions. Regexes gain <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kotlinlang.org\/docs\/whatsnew16.html#splitting-regex-into-a-sequence\">sequence split functions<\/a> and consistent behavior for <code>replace()<\/code> and <code>replaceFirst()<\/code> across Java and JavaScript environments.<\/p>\n<p>Some existing functions <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kotlinlang.org\/docs\/whatsnew16.html#splitting-regex-into-a-sequence\">have been deprecated<\/a>. The <code>concat()<\/code>, <code>match()<\/code>, and <code>matches()<\/code> functions on strings, as well as the <code>sort()<\/code> function on arrays, will now issue warnings. Their functionality is already covered by alternative options.<\/p>\n<h2 id=\"other-changes\"><span class=\"ez-toc-section\" id=\"Other_Changes\"><\/span>Other Changes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Kotlin 1.6 adds a few ecosystem enhancements and quality-of-life improvements. Among these is support for Xcode 13 and the ability to compile Windows builds on any platform. If you\u2019re targeting <code>mingwX64<\/code> or <code>mingwX86<\/code> for Windows, you can now compile from any system that supports Kotlin\/Native development.<\/p>\n<p>Improvements <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kotlinlang.org\/docs\/whatsnew16.html#performance-improvements\">to compiler caches<\/a> for Linux and iOS builds have halved typical build times after the first run. Updates to the Kotlin dependency chain significantly reduce disk usage. Switching to LLVM 11.1 <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kotlinlang.org\/docs\/whatsnew16.html#llvm-and-linker-updates\">has cut the<\/a> macOS version from 1200 MB to around 300 MB.<\/p>\n<p>If you\u2019re using Kotlin JavaScript, you can now <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kotlinlang.org\/docs\/whatsnew16.html#option-to-use-pre-installed-node-js-and-yarn\">disable automatic downloads<\/a> of Node.js and Yarn during the build process. This is useful when you\u2019re compiling code in a preconfigured environment where the host already has these dependencies installed.<\/p>\n<h2 id=\"summary\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Kotlin 1.6 is a healthy release with new experimental features paving the way forwards and a good roster of language and standard library changes that you can use today. There have also been improvements to interoperability between Kotlin flavors so more code will behave the same whether it\u2019s compiled for JVM, Native, or JavaScript.<\/p>\n<p>The 1.6 milestone also sees Kotlin\u2019s maintainers offer an extended support period for older API versions. Three previous versions will now be supported on a rolling cadence. This means you can currently choose to develop against Kotlin versions 1.3 to 1.6, giving you more time to upgrade between releases.<\/p>\n<p>You can move to Kotlin 1.6 today by updating your version of IntelliJ IDEA, Android Studio, Xcode, or the Kotlin CLI compiler. It\u2019s worth reviewing the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kotlinlang.org\/docs\/compatibility-guide-16.html\">compatibility guide<\/a> first to make sure you\u2019ve addressed all the previously reported deprecations that will throw warnings or errors in 1.6.\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/14904\/whats-new-in-kotlin-1-6\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#What\u2019s New In Kotlin 1.6? \u2013 CloudSavvy IT&#8221; Trismegist san\/Shutterstock.com Kotlin 1.6 is out with new features, an improved experimental memory manager, and an enhanced standard library. The additions help mature JetBrains\u2019 increasingly popular cross-platform and cross-discipline language. New Native Memory Manager Arguably the biggest change for the Kotlin ecosystem is the arrival of the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":380823,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/2464a0d1.jpg","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-380822","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/380822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=380822"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/380822\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/380823"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=380822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=380822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=380822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}