官术网_书友最值得收藏!

There's more...

The Kotlin standard library uses the infix notation extensively. You can benefit from infix functions to shape your code the clean way. One infix function worth noting is the to() extension function provided for the Map.Entry<K, V> class, which allows you to declare map entries in a minimalistic way:

val namesWithBirthdays: Map<String, LocalDate> =
mapOf("Agata" to LocalDate.of(1990, 1, 18))

The to() extension function is declared for a generic type A and generic argument of type B, which returns an instance of a Pair<A, B> class.

There are plenty of other functions supporting infix notations available in the standard library. If you check the implementation of the ones you are using on a daily basis, it may turn out they are available in the infix form too.

主站蜘蛛池模板: 西宁市| 田林县| 曲靖市| 信丰县| 尉氏县| 磐安县| 全南县| 三明市| 淮滨县| 麻江县| 遵义市| 思南县| 莲花县| 广饶县| 滁州市| 盐山县| 白山市| 嘉义县| 苏尼特右旗| 白城市| 和政县| 阿坝县| 漯河市| 新干县| 江城| 吉木萨尔县| 泾川县| 江永县| 文化| 洪泽县| 威海市| 通州区| 天峨县| 镇安县| 镇江市| 鹿邑县| 正宁县| 镶黄旗| 福安市| 长顺县| 宜良县|