- Kotlin Standard Library Cookbook
- Samuel Urbanowicz
- 109字
- 2021-07-23 19:05:46
Getting ready
The Kotlin standard library provides functions that allow the declaration of ranges for the integral, primitive types, such as Int, Long, and Char. To define a new range instance, we can use the rangeTo() function. For example, we can declare a range of integers from 0 to 1000 in the following way:
val range: IntRange = 0.rangeTo(1000)
The rangeTo() function has also its own special operator equivalent, .., which allows the declaration of a range with a more natural syntax:
val range: IntRange = 0..1000
Also, in order to declare a range of elements in a decreasing order, we can use the downTo() function.
推薦閱讀
- C語(yǔ)言程序設(shè)計(jì)實(shí)踐教程(第2版)
- jQuery EasyUI網(wǎng)站開(kāi)發(fā)實(shí)戰(zhàn)
- 看透JavaScript:原理、方法與實(shí)踐
- Python程序設(shè)計(jì)案例教程
- 數(shù)據(jù)結(jié)構(gòu)習(xí)題解析與實(shí)驗(yàn)指導(dǎo)
- Android開(kāi)發(fā)案例教程與項(xiàng)目實(shí)戰(zhàn)(在線實(shí)驗(yàn)+在線自測(cè))
- RSpec Essentials
- Protocol-Oriented Programming with Swift
- 51單片機(jī)C語(yǔ)言開(kāi)發(fā)教程
- SSM開(kāi)發(fā)實(shí)戰(zhàn)教程(Spring+Spring MVC+MyBatis)
- 軟件項(xiàng)目管理實(shí)用教程
- 創(chuàng)意UI:Photoshop玩轉(zhuǎn)APP設(shè)計(jì)
- 從0到1:HTML5 Canvas動(dòng)畫(huà)開(kāi)發(fā)
- jQuery for Designers Beginner's Guide Second Edition
- 軟件設(shè)計(jì)模式(Java版)