Created
May 22, 2020 12:08
-
-
Save ruurtjan/6b0e4c6e38564603d5d29e549209e16a to your computer and use it in GitHub Desktop.
functional-dsl-blog-9.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class EmailFilter(run: Email => Boolean) { self => | |
def &&(that: EmailFilter): EmailFilter = | |
EmailFilter(email => self.run(email) && that.run(email)) | |
def ||(that: EmailFilter): EmailFilter = | |
EmailFilter(email => self.run(email) || that.run(email)) | |
def negate : EmailFilter = | |
EmailFilter(email => !self.run(email)) | |
} | |
object EmailFilter { | |
val always: EmailFilter = EmailFilter(_ => true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment