Closed h0bb3 closed 4 years ago
Hi, I fixed that in the test branch, I'll merge it back soon and query you again :)
pushed, let me know
Confirmed working on both windows and osx. Nice, I'm closing this now...
btw, another solution, to the problems above mentioned, could be that one of creating a specific class for containing both the String and the vararg arguments.. this would have a runtime cost though..
At the moment I opted for having a single function (such as formatString
without V
) accepting vararg
When using tooltips with variable arguments a java java.util.IllegalFormatConversionException is thrown.
You can reproduce this by opening the demo/widgets/plots and hovering mouse over a plot.
This is because the arguments in themselves are wrapped in array, i.e. setTooltip calls
text, text calls formatStringV
one must remember to use the spread operator * (which is not done in tooltips.setTooltip). This would be the easy fix.
However, would also suggest to not use vararg in formatStringV as it can be prone to mistakes and instead use an array. The function signature would then be:
fun formatStringV(buf: ByteArray, fmt: String, args: Array): Int
This would not solve the problem of anyone using text from a function with vararg and forgetting to use spread. To guard for this there is however the possibility to add:
fun text(fmt: String, argsArray: Array, vararg args: Any) {
text(fmt, argsArray, args)
}
This seems to work well though could be considered too defensive, possibly confusing, and promoting "sloppy coding".
There could also be other ways to solve such issues in Kotlin that I'm not aware of...