another question where i am not even sure where to...
# getting-started
n
another question where i am not even sure where to begin searching.. is there a annotation that lets the user know that something else might be cleaner and replace code that is less severe than
@Deprecated
usecase is a DSL
j
Would use
@Deprecated
on warning level
n
cool, thanks, setting the level actually helps me in a few more places
s
Not to mention, @Deprecated could also be used with @ReplaceWith as well https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-replace-with/index.html
n
i have no idea how to use ReplaceWith though.. i wand to do this
id(SomeExpression)
->
+ someExpression
and ideally in the case that the lambda is specified do
id(someExpression) { moreExpressions }
->
add(someExpression) { moreExpressions }
is there some kind of printf like syntax that can be used in
ReplaceWith
that i do not know about ?
s
@Nikky something like this helps IDE do the actual replacement
Copy code
@Deprecated("Use fooBar()",
        replaceWith = ReplaceWith("fooBar()"))
fun fooBar( value : Int ): Unit = println( "old one" )

fun fooBar() = println( "new one" )
fun main( argv : Array<String> ) {
    fooBar(1)
}
n
yeah so far i understand but that is plainly said.. useless without the ability to automatically refactor some parts of the expression.. what if you did not want to loose the argument ? in your example it just gets dropped