Deprecate Char-to-Number conversions in stdlib (JVM and JS)
- Int.toChar was left non-deprecated because the replacement is not intrinsic yet. - Number.toChar was left non-deprecated because otherwise the deprecation propagates to the override, Int.toChar. KT-23451
This commit is contained in:
@@ -84,7 +84,7 @@ public fun LongRange.random(random: Random): Long {
|
||||
@SinceKotlin("1.3")
|
||||
public fun CharRange.random(random: Random): Char {
|
||||
try {
|
||||
return random.nextInt(first.toInt(), last.toInt() + 1).toChar()
|
||||
return random.nextInt(first.code, last.code + 1).toChar()
|
||||
} catch(e: IllegalArgumentException) {
|
||||
throw NoSuchElementException(e.message)
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public fun LongRange.randomOrNull(random: Random): Long? {
|
||||
public fun CharRange.randomOrNull(random: Random): Char? {
|
||||
if (isEmpty())
|
||||
return null
|
||||
return random.nextInt(first.toInt(), last.toInt() + 1).toChar()
|
||||
return random.nextInt(first.code, last.code + 1).toChar()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user