There should be a ```inline fun <T> T?.print...
# language-proposals
e
There should be a
Copy code
inline fun <T> T?.println(): T? {
    println(this)
    return this
}
so I dont have to move my caret around when trying to debug
👍 1
d
How you will print empty line, if such function would exist?
e
println()
Im not saying to get rid of the original println, just add a extension method to easily print an object inline
d
Copy code
class A {
    fun test() {
        println()
    }
}
Does it print empty line or
A
?
e
I see... so in this case you can't print an empty line without using the full qualified name...
d
Yep
e
You could just call it something else
Like
printObject
or something
or
printAndReturn
d
Do you have any usecases except debugging?
y
There's already an idiomatic pattern to do this btw:
Copy code
objectOrLongExpression.also(::println).continueMethodChain()
In general,
also
is used to perform some side effect and then continue a method chain.
8
e
hmm I never thought about it that way
But yeah, not really a usecase outside of debugging I would say
I mean the usage of println is kinda limited in the first place right?
s
there's also the IntelliJ suffix template stuff