https://kotlinlang.org logo
#feed
Title
# feed
u

Uberto Barbini

04/02/2019, 8:15 AM
Why inheriting from a function in Kotlin can be a good idea and some considerations on invoke operator https://proandroiddev.com/kotlin-pearls-3-its-an-object-it-s-a-function-it-s-an-invokable-bc4bfed2e63f
👍 7
❤️ 1
👏 6
e

elect

04/02/2019, 9:05 AM
I didnt know about the possibility to extend classes from functions..
s

streetsofboston

04/02/2019, 11:20 AM
Lambda-types, which you can use as base-classes, are Kotlin's single-method-interfaces. I tend to use typealias with them, not so much as a base-class. Then I can still assign a value that is a simple closure
= { ... }
, not an
= object : xxxx
d

Dmitry Kandalov

04/02/2019, 12:34 PM
Good blog 🙂 Unfortunately, there is pretty much no navigation (e.g. find usages/subclasses) for Kotlin function types in IntelliJ. For this reason on one of the projects we replaced most of the “functional objects” with interfaces (i.e. nominal types) so we can reliably navigate and refactor the codebase.
(I wonder if there is youtrack issue for navigating functional types.)
u

Uberto Barbini

04/02/2019, 7:57 PM
In Haskell we have Hoogle... maybe it's time to have something similar for Kotlin? 🙂
but to be honest I never had the necessity to look for class that inherited a given function
d

Dmitry Kandalov

04/02/2019, 9:09 PM
Hm, I should probably remember what we wanted but couldn’t do with navigation and find or create youtrack issue 🤔
u

Uberto Barbini

04/02/2019, 9:11 PM
my secret is that I always use copy-paste, so I don't have to navigate 🙂
Some vegetable curry ;)
😁 1
a

Alexey Belkov [JB]

04/04/2019, 5:09 PM
The issue is probably https://youtrack.jetbrains.com/issue/KT-13714 or the related one.
👍 2
s

Sergey Burlaka

04/04/2019, 8:02 PM
oh thanks @Uberto Barbini. Now after reading your posts and Kotlin documantaions on medium i have understud how function as apply{} or run{} works in Kotlin This function: fun <T,S> T.runAny(str: T.() -> S): S { return str() }
❤️ 1
d

Dmitry Kandalov

04/04/2019, 9:14 PM
@Alexey Belkov [JB] yes, and also things like you cannot see hierarchy of subclasses for a functional type. E.g. I’d want to ctrl+alt click on
(String) -> Int
type, see list of classes implementing it and jump to implementation. Or search for all usages of type
(String) -> Int
. Although probably once the issues you mentioned are fixed, everything will start working.
a

Alexey Belkov [JB]

04/05/2019, 8:03 AM
I wouldn't be so optimistic about "everything will start working" 🙂 Please file an issue about functional types when you have the time.
👍 1
4 Views