1 package frost.core
2
3 ====================================================================================================
4 Provides the [format] function, which allows objects to be formatted according to a *format string*.
5 The format string's meaning is defined by the object being formatted.
6
7 Format strings may be provided to formattable objects during string interpolation, using the syntax
8 `"\{value:format}"`. For instance,
9
10 def value := 255
11 Console.printLine("\{value} in hexadecimal is: \{value:X}")
12
13 This calls `value.format("X")`, which is understood by the [Int64] class to mean "format this number
14 in uppercase hexadecimal". This results in the output:
15
16 255 in hexadecimal is: FF
17
18 and is equivalent to having written:
19
20 Console.printLine(value + " in hexadecimal is: " + value.format("X"))
21 ====================================================================================================
22 interface Formattable {
23 function format(fmt:String):String
24 }