LibreTube/app/src/main/java/com/github/libretube/extensions/GetWhileDigit.kt

11 lines
254 B
Kotlin

package com.github.libretube.extensions
/**
* Read a string as long as the char is a digit and return the number value as int
*/
fun String?.getWhileDigit(): Int? {
return orEmpty().takeWhile { char ->
char.isDigit()
}.toIntOrNull()
}