The Kotlin documentation says this about fun inter...
# functional
j
The Kotlin documentation says this about fun interface vs type alias
• If your API needs to accept a function (any function) with some specific parameter and return types – use a simple functional type or define a type alias to give a shorter name to the corresponding functional type.
• If your API accepts a more complex entity than a function – for example, it has non-trivial contracts and/or operations on it that can’t be expressed in a functional type’s signature – declare a separate functional interface for it.
Do you have any examples where a type aliases wouldn’t be enough and one could leverage a fun interface instead? I’ve been using fun interfaces for a while but they could all be replaced with type aliases I think
c
a “type alias” is, well, just that - an alias; callers can pass anything that matches the underlying type, i.e. they aren’t required to use the alias. They afford no type safety; if you need type safety, use a type.