is there a standard of when to use higher order fu...
# announcements
a
is there a standard of when to use higher order functions vs interfaces with one method?
maybe it is just me, but
val permissions = HashSet<(CommandSender) -> Boolean>()
seems slightly jank
also HOF don't really specify what the function is doing whereas interfaces do
is having two functions, one accepting an interface and one accepting a HOF redundant? (HOF would be wrapped in interface)
s
conversely, interfaces generally don’t tell you what the function takes and returns
if you find yourself writing this type out a lot, maybe a typealias is a good middle ground?
a
yeah, probably
g
honestly, seems like HOF is often preferable even in case of interfaces with multiple functions. It's more granular and flexible this way. A good example would be
TextWatcher
on Andorid that got splitted into separate lambdas in ktx library.