https://kotlinlang.org logo
#intellij
Title
# intellij
m

mbonnin

11/14/2023, 10:22 AM
Not 100% sure where to ask this but out of curiosity, is there a compiler plugin or IDE plugin that can tell me when I pass wrong positional arguments to
String.format
?
Copy code
// I'd like this to fail at compile time and/or show me an error in the IDE
String.format("%d", "10")
k

Klitos Kyriacou

11/14/2023, 10:28 AM
Interestingly, it already does, but only for Java files.
👀 1
👍 1
blob thinking upside down 1
m

mbonnin

11/14/2023, 10:29 AM
Ah thanks! I thought I'd seen this somewhere
But haven't been able to make it work in Kotlin files so far
e

Eugen Martynov

11/15/2023, 12:36 PM
I think Android lint does same for the Android strings
👍 1
t

twisterrob

11/17/2023, 12:47 AM
what happens if you use the Kotlin syntax?
"%d".format(10)
?
m

mbonnin

11/17/2023, 10:21 AM
@twisterrob same thing (i.e. no warning/error)
e

ephemient

11/23/2023, 1:37 AM
m

mbonnin

11/23/2023, 10:12 AM
Good find, upvoted!
2 Views