suffix

Common
JVM
JS
Native
1.0
var suffix: String
(source)

Defines NumberHexFormat.suffix of the format being built, empty string by default.

The string must not contain line feed (LF) and carriage return (CR) characters.

Refer to NumberHexFormat.suffix for details about how the format option affects the formatting and parsing results.

import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
// By default, `suffix` is an empty string
println(0x3a.toHexString()) // 0000003a
println("0000003a".hexToInt()) // 58

val suffixFormat = HexFormat { number.suffix = "h" }

// `suffix` is placed after the hex representation
println(0x3a.toHexString(suffixFormat)) // 0000003ah
println("0000003ah".hexToByte(suffixFormat)) // 58

// Parsing `suffix` is conducted in a case-insensitive manner
println("0000003aH".hexToInt(suffixFormat)) // 58

// Parsing fails if the input string does not end with the specified suffix.
// "0000003a".hexToInt(suffixFormat) // will fail with IllegalArgumentException
//sampleEnd
}

Exceptions

IllegalArgumentException - if a string containing LF or CR character is assigned to this property.