compareTo
将此对象与指定对象进行比较以进行排序。如果此对象等于指定的其他对象,则返回零,如果小于 other,则返回负数,如果大于 other,则返回正数。
1 | operator fun compareTo(other: String): Int |
contains
检查原字符串中时候包含给定字符或字符串或正则表达式
1 | inline operator fun CharSequence.contains(regex: Regex): Boolean |
drop
返回移除了前 n 个字符的字符串
1 | fun String.drop(n: Int): String |
length
获取字符串的长度
1 | val length: Int // 定义 |
plus
返回通过将此字符串与给定其他对象的字符串表示形式连接获得的字符串。
1 | operator fun plus(other: Any?): String // 定义 |
repeat
返回将原字符串重复 n 次后的新字符串。当 n = 0 时,返回空字符串
1 | actual fun CharSequence.repeat(n: Int): String |
split
使用指定模式或字符串或字符分割原字符串
1 | fun CharSequence.split(regex: Pattern, limit: Int = 0) |
int 常用函数
- dec(): 返回此值减一。
- inc(): 返回此值加一
- div(int): 将此值除以另一个值,将结果截断为更接近零的整数
- minus(int): 从这个值中减去另一个值。
- plus(int): 将其他值添加到此值。
- rem(int): 计算此值除以其他值的截断余数
- coerceAtLeast(min): 确保此值不小于指定的最小值
- coerceAtMost(max): 确保此值不大于指定的最大值