First, as @pedrofurla points out in his comment, currying has nothing to do with what you're seeing here. Second, while LoggingAction
and Action
behave similarly from the perspective of an API user, it's important to distinguish between them.
Action
is capitalized by convention because it is the name of a class and a companion object. This may not be obvious from the context since it appears that Action
is being called like a function, but what's really going on is more subtle. Since the Action
companion object defines an apply
method,
Action(arg)
is treated as shorthand for
Action.apply(arg)
That is, what looks like a function invocation is really just an invocation of the Action
object's apply
method. In cases like this where a method takes a single function as an argument it's common to use braces:
Action apply { request =>
// ...
}
LoggingAction
, on the other hand, is a method. Uppercase method names are not conventional and could potentially confuse users of the API. However, it may be appropriate in cases like this one, since it creates consistency throughout the API. Generally, the intent of such usage is to make it clear that the call is creating some thing (here, a logging action) rather than doing something. A rough rule of thumb is that a capital letter indicates a noun, while a lowercase indicates a verb.