Skip to content

Instantly share code, notes, and snippets.

@sammyrulez
Created April 28, 2016 14:51
Show Gist options
  • Save sammyrulez/6430b676eb078b4e5c10d5ae5dd86171 to your computer and use it in GitHub Desktop.
Save sammyrulez/6430b676eb078b4e5c10d5ae5dd86171 to your computer and use it in GitHub Desktop.
funtional aop
object Wrapper {
def apply[A,B](before:A=>A,fn:A=>B,after:B=>B):A=>B = {
def wrapped(a:A):B = {
after(fn(before(a)))
}
return wrapped
}
}
@sammyrulez
Copy link
Author

sammyrulez commented Apr 28, 2016

val bStrInt: ((String, Int)) => (String, Int) = tupleX =>("",0)

  val myFn: ((String, Int)) => String = tupleX => (tupleX._1 + tupleX._2)


  val afterStr: (String) => String = tupleY => tupleY

  def callingUsecase()= {

    apply[(String,Int),(String)](bStrInt,myFn,afterStr)

  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment