October 2021
Intermediate to advanced
500 pages
16h 23m
English
To specify that you want your numbers to be formatted as currency, you will need to use a different constructor than the one you stubbed out in the external definition of Intl.NumberFormat. This new constructor will take two arguments: a locale and an optional set of formatting specifications. To begin, specify the locale parameter. You will declare the options parameter later (for now, your code will use the default set of options).
Listing 26.11 Declaring a second constructor (jsMain/kotlin/Intl.kt)
external class Intl {
class NumberFormat {
constructor()
constructor(locale: String)
fun format(number: Number): String
}
}
This parameter specifies the locale of the user. It affects formatting options ...
Read now
Unlock full access