I have this code. The method returns a (User, Acl, Tree) tuple. Instead of accessing the data with _._1, _._2
etc I use match. Is there an easier(better) way then what I'm doing? Thanks
User.findUserJoinAclTree(3).map {
_ match {
case(user, acl, tree) =>
Logger.info(user.email)
Logger.info(acl.id)
Logger.info(tree.name)
}
}
Your expression can be simplified a bit:
User.findUserJoinAclTree(3) map {
case (user,_,_) => Logger.info(user.email)
}
First, you don't need to match the arguments, you can directly pass a partial function to map, then you can use wildcard (_) for the the tuple elements you don't need
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With