while reading someone’s code in kotlin, i found ou...
# getting-started
h
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
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
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