https://kotlinlang.org logo
#getting-started
Title
# getting-started
a

Ayfri

07/28/2021, 3:08 PM
Hi, I know that there are names for specific functions, like a function with an argument that returns a Boolean is a Predicate, but is there a name for a function that has an argument of type T and returns the same type ? Like this
typealias IDK<T> = (value: T) -> T
r

Ruckus

07/28/2021, 3:19 PM
It's not really named based on the types, but more on the expected use. For example, it's not a predicate because it returns a Boolean, it's a predicate because it's a statement about the information passed in. A predicate could take multiple arguments (and depending on the domain could theoretically return something other than a Boolean, though that's more rare and domain specific), and a function that returns a Boolean may not nesessarily be a predicate. So, to answer your question, how to name your alias depends on it's expected use. As @Landry Norris said, transform[ation] and mutator make sense when you're respectively transforming or mutating the value, but if you have no information about the use, your best bet would probably just be "function" or a synonym (operation, action, etc.).
v

Vampire

07/28/2021, 5:13 PM
ThingDoer
🙂
👍 1
😆 3
n

nwh

07/28/2021, 5:41 PM
l

Ludovik

07/28/2021, 5:55 PM
A monad
🧌 3
y

Youssef Shoaib [MOD]

07/29/2021, 8:12 AM
@Ludovik b-but but it's not a monoid in the category of endofunctors!!!!!!!!!!!!!!!
v

Vampire

07/29/2021, 1:49 PM
Better Monad than Maenad
a

Ayfri

07/29/2021, 2:53 PM
Thanks for the help everyone !