- Functional Kotlin
- Mario Arias Rivu Chakraborty
- 199字
- 2021-06-24 19:15:27
Implementing immutability in Kotlin
Unlike Clojure, Haskell, F#, and the likes, Kotlin is not a pure functional programming language, where immutability is forced; rather, we may refer to Kotlin as a perfect blend of functional programming and OOP languages. It contains the major benefits of both worlds. So, instead of forcing immutability like pure functional programming languages, Kotlin encourages immutability, giving it automatic preference wherever possible.
In other words, Kotlin has immutable variables (val), but no language mechanisms that would guarantee true deep immutability of the state. If a val variable references a mutable object, its contents can still be modified. We will have a more elaborate discussion and a deeper dive on this topic, but first let us have a look at how we can get referential immutability in Kotlin and the differences between var, val, and const val.
- JavaScript前端開發(fā)模塊化教程
- Kubernetes實戰(zhàn)
- C語言程序設(shè)計
- 游戲程序設(shè)計教程
- WordPress Plugin Development Cookbook(Second Edition)
- 深度學(xué)習(xí):算法入門與Keras編程實踐
- Gradle for Android
- Nginx實戰(zhàn):基于Lua語言的配置、開發(fā)與架構(gòu)詳解
- Python極簡講義:一本書入門數(shù)據(jù)分析與機器學(xué)習(xí)
- INSTANT Yii 1.1 Application Development Starter
- 算法超簡單:趣味游戲帶你輕松入門與實踐
- Microsoft Dynamics GP 2013 Cookbook
- Flask開發(fā)Web搜索引擎入門與實戰(zhàn)
- Flutter for Beginners
- Alfresco for Administrators