I need to pass `vararg args: Any` down the functi...
# announcements
e
I need to pass
vararg args: Any
down the function stack, in order to format later a
String
. However I keep getting
IllegalFormatConversionException
Copy code
logDebug("WindowRef %08X", ref.id) // ref.id is an Int

fun logDebug(fmt: String, vararg args: Any) {

   val toAppend = fmt.format(args) // IllegalFormatConversionException
   ...
}
i
Try to pass them with the spread operator:
*args
e
it worked..
why is this necessary since
format
also accept vararg?
t
vararg Any
is not a type in itself, it becomes an
Array<Any>
once used, so you need to pass this array using the spread operator
*