Dmitry Kandalov on Nostr: I don't remember if I ever really needed it, but you can have higher-order extension ...
I don't remember if I ever really needed it, but you can have higher-order extension functions in #Kotlin. For example:
fun f(): Int.() -> Int =
{ this + 1 }
fun main() {
val extF = f()
require(42.extF() == 43)
}
Published at
2024-07-19 15:47:16Event JSON
{
"id": "f8cc24172bee177bf7444bd05502ae4aba63a158e10f81a759e88e3b17070792",
"pubkey": "864bf94bd0d4548dc944d6a5a49823d32bf4c1de273d4f7376fad8f82e163a42",
"created_at": 1721404036,
"kind": 1,
"tags": [
[
"t",
"kotlin"
],
[
"proxy",
"https://mastodon.social/users/dkandalov/statuses/112813934952516434",
"activitypub"
]
],
"content": "I don't remember if I ever really needed it, but you can have higher-order extension functions in #Kotlin. For example: \n\nfun f(): Int.() -\u003e Int =\n { this + 1 }\n\nfun main() {\n val extF = f()\n require(42.extF() == 43)\n}",
"sig": "944540bfbeecf84f00888cf571464fa183d10bb4b0bbccc7937eec7e9cb4af0733ac0a17b864965e97a96717994a55de8716b2457c6ccfa595c4087400d11ec5"
}