I see this type of template ( found this example here ) quite often in Scala:
class UserActor extends Actor { def receive = { case GetUser(id) =>
Therefore, depending on the call received: Option [User], List [User], Right [User]. This approach is great! I'm just asking out of interest if this is optimal? For example (and this may be bad): will this make the API better or worse to try to generalize, always returning List [User]? Therefore, when the user is not found or if the failure failed, the list will simply be empty. I'm just wondering ... any other suggestions on how to improve the above "template"?
I'm just trying to determine the perfect template for this API style, where you sometimes get one object, and sometimes none, and sometimes a list of them. Is there a “better” way to do this, or does everyone play a role?
source share