Skip to content

Instantly share code, notes, and snippets.

@itang
Created December 28, 2021 10:38
Show Gist options
  • Save itang/2f79737b8d2afe226d021711a35e9a93 to your computer and use it in GitHub Desktop.
Save itang/2f79737b8d2afe226d021711a35e9a93 to your computer and use it in GitHub Desktop.
extension [A, B] (t: Tuple2[A, B])
inline infix def ||>[C](inline f: (A, B) => C): C =
f(t._1, t._2)
extension [T] (t: T)
infix def |>[B](f: T => B): B =
f(t)
def add(a:Int, b: Int):String = (a + b).toString
@main
def main():Unit =
(1, 2) ||> add |> println
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment