Navigation
Search
|
Kotlin previews guard conditions in when expressions
Tuesday December 3, 2024. 10:34 PM , from InfoWorld
JetBrains has released Kotlin 2.1.0, an update to the Kotlin programming language that previews guard conditions and has compiler updates offering flexibility around checks.
Released November 27, Kotlin 2.1.0 can be installed as an update by following the instructions at kotlinlang.org. Kotlin 2.1.0 introduces several language improvements in preview. One preview feature allows developers to use guard conditions in when expressions with subjects. Guard conditions let developers include more than one condition for branches of a when expression, making complex control flows more explicit and concise while also flattening code structure, JetBrains said. A second preview feature is the ability to use non-local break and continue. This feature expands the tool set developers can use in the scope of inline functions and reduces boilerplate code. A third preview feature introduces support for multi-dollar string interpolation, improving how the dollar sign ($) is handled within string literals. This helps with contexts that require multiple dollar signs, such as templating engines, JSON schemas, or other data formats, JetBrains said. Also in Kotlin 2.1.0, Kotlin Multiplatform introduces basic support for Swift export and makes it easier to publish Kotlin Multiplatform libraries. Swift export allows for exporting Swift sources directly to the Swift interface without using Objective-C headers. Improvements around the Gradle build tool pertaining to Kotlin Multiplatform, meanwhile, stabilize a new DSL for configuring compiler options. An Isolated Projects feature to improve Gradle performance is included in a preview. The K2 compiler in Kotlin 2.1.0 adds the ability to suppress warnings globally and enables additional checks, including extra declaration, expression, and type checks that are usually not crucial for compilation but can be useful for validating use cases such as REDUNDANT_NULLIBLE and CAN_BE_VAL. Other improvements in Kotlin 2.1.0: Kotlin/Native upgrades iosArm64 target support including the cinterop caching process and other updates. Kotlin/Wasm supports incremental compilation for Wasm targets. In development tasks, the compiler now recompiles only files relevant to changes from the last compilation, reducing compilation time. Also, debugging has been improved for Kotlin/Wasm and the size of Kotlin/Wasm binaries has been reduced. Kotlin/JS adds support for generating ES2015 arrow functions, such as (a, b) => expression, instead of anonymous functions. Kotlin 2.1.0 follows the May release of Kotlin 2.0.0, which brought the new K2 compiler to a stable state. Kotlin plugins that support version 2.1.0 are bundled in the latest IntelliJ IDEA and Android Studio IDEs.
https://www.infoworld.com/article/3616514/kotlin-previews-guard-conditions-in-when-expressions.html
Related News |
25 sources
Current Date
Dec, Wed 4 - 20:05 CET
|