https://kotlinlang.org logo
#getting-started
Title
# getting-started
h

Hassaan

10/18/2023, 12:49 PM
while reading someone’s code in kotlin, i found out “<” of some use in formatting and is equivalent to the last argument used before it (and same goes with java).
fun printOctAndHex(value: Int) {
print("%#o *%<#x*".format(v))
}
my question is where to find this in documentation ? where is it mentioned ? and how to know about such similar things? this question may be naive to you and sorry for that in advance but i don’t quite get it
c

CLOVIS

10/18/2023, 12:56 PM
Sadly, this is not documented as part of the Kotlin language. However, it is documented in the Java documentation of the
Formatter
class (CTRL F
%<
): https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html
k

Klitos Kyriacou

10/18/2023, 2:27 PM
It's only supported on the JVM anyway. There's a ticket to add it to the common library: https://youtrack.jetbrains.com/issue/KT-25506/Stdlib-String.format-in-common