Not a problem but a mere curiosity; is there any m...
# stdlib
d
Not a problem but a mere curiosity; is there any more 'first class' way of writing
{ it }
where for a single parameter lambda that merely pipes-through its input value?
e
hmm. you could define a
Copy code
fun <T> identity(): (T) -> T = { it }
similar to Java's Function.identity(), but I don't think it would be any easier to use than
{ it }
👍 1
d
I agree it would be pointlessly obfuscating to define a new function for it.
o
@darkmoon_uk I do not understand the question, can you give an example?
j
mine: borrowing from the brief amount of lectures on Categorical notation i caught.
Copy code
/**right identity*/
inline val <reified T> T.`⟲`
    get() = { this }
Copy code
1.`⟲`
"const".`⟲`
(args[1]).`⟲`
o
what am i looking at
j
: () -> T
sometimes you don't want to commit to a feature being mutable or immutable in your design, so you can use ()->T instead