- Functional Kotlin
- Mario Arias Rivu Chakraborty
- 110字
- 2021-06-24 19:15:25
Canonical methods
Canonical methods are the methods declared in Any. Therefore, all instances in Kotlin have them.
For data classes, Kotlin creates correct implementations of all canonical methods.
The methods are as follows:
- equals(other: Any?): Boolean: This method compares value equivalence, rather than reference.
- hashCode(): Int: A hash code is a numerical representation of an instance. When hashCode() is invoked several times in the same instance, it should always return the same value. Two instances that return true when they are compared with equals must have the same hashCode().
- toString(): String: A String representation of an instance. This method will be invoked when an instance is concatenated to a String.
推薦閱讀
- 零基礎PHP學習筆記
- Mastering ServiceStack
- Java面向對象思想與程序設計
- 軟件測試工程師面試秘籍
- Python機器學習編程與實戰
- Hands-On Enterprise Automation with Python.
- Drupal 8 Module Development
- Developing SSRS Reports for Dynamics AX
- Modern C++ Programming Cookbook
- Clean Code in C#
- Python 3 數據分析與機器學習實戰
- Managing Microsoft Hybrid Clouds
- Webpack實戰:入門、進階與調優(第2版)
- 零基礎看圖學ScratchJr:少兒趣味編程(全彩大字版)
- Elasticsearch Blueprints