isWhitespace

expect fun Char.isWhitespace(): Boolean

Determines whether a character is whitespace according to the Unicode standard. Returns true if the character is whitespace.

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = listOf(' ', '\t', '\n', '1', 'a', '\u00A0')
val (whitespaces, notWhitespaces) = chars.partition { it.isWhitespace() }
// whitespace char codes
assertPrints(whitespaces.map(Char::code), "[32, 9, 10, 160]")
// non-whitespace chars
assertPrints(notWhitespaces, "[1, a]") 
   //sampleEnd
}
actual fun Char.isWhitespace(): Boolean

Determines whether a character is whitespace according to the Unicode standard. Returns true if the character is whitespace.

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = listOf(' ', '\t', '\n', '1', 'a', '\u00A0')
val (whitespaces, notWhitespaces) = chars.partition { it.isWhitespace() }
// whitespace char codes
assertPrints(whitespaces.map(Char::code), "[32, 9, 10, 160]")
// non-whitespace chars
assertPrints(notWhitespaces, "[1, a]") 
   //sampleEnd
}
actual fun Char.isWhitespace(): Boolean

Determines whether a character is whitespace according to the Unicode standard. Returns true if the character is whitespace.

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = listOf(' ', '\t', '\n', '1', 'a', '\u00A0')
val (whitespaces, notWhitespaces) = chars.partition { it.isWhitespace() }
// whitespace char codes
assertPrints(whitespaces.map(Char::code), "[32, 9, 10, 160]")
// non-whitespace chars
assertPrints(notWhitespaces, "[1, a]") 
   //sampleEnd
}
actual fun Char.isWhitespace(): Boolean

Determines whether a character is whitespace according to the Unicode standard. Returns true if the character is whitespace.

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = listOf(' ', '\t', '\n', '1', 'a', '\u00A0')
val (whitespaces, notWhitespaces) = chars.partition { it.isWhitespace() }
// whitespace char codes
assertPrints(whitespaces.map(Char::code), "[32, 9, 10, 160]")
// non-whitespace chars
assertPrints(notWhitespaces, "[1, a]") 
   //sampleEnd
}