Skip to content

Instantly share code, notes, and snippets.

@dabrowski-adam
Created September 18, 2024 22:52
Show Gist options
  • Save dabrowski-adam/193b6ede9d22ac99f6a773a174173c70 to your computer and use it in GitHub Desktop.
Save dabrowski-adam/193b6ede9d22ac99f6a773a174173c70 to your computer and use it in GitHub Desktop.
Pipe operator for Scala 3
//> using scala 3.5.0
package com.adamdabrowski.pipe
import scala.annotation.targetName
extension [A](x: => A)
@targetName("pipe")
inline def |>[B](inline f: A => B): B = f(x)
@targetName("pipeByName")
inline def |>[B](inline f: (=> A) => B): B = f(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment