Last active
February 26, 2021 20:08
-
-
Save deanwampler/56bbdbd3129a76f594f9ff9a2e7cb48a to your computer and use it in GitHub Desktop.
ArrowAssoc replaced with an extension method
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
// From https://github.com/deanwampler/programming-scala-book-code-examples/ | |
import scala.annotation.targetName | |
extension [A,B] (a: A) | |
@targetName("arrow2") def ~>(b: B): (A, B) = (a, b) | |
// Alternative, where the [B] goes on the method instead. Support for this alternative was | |
// introduced in Scala 3.0.0-RC1. This form is closer to what we're used to doing with | |
// normal parameterized types and methods that take additional type parameters. the type | |
// signature for the two ~> methods will be slightly different, but they work the same. | |
extension [A] (a: A) | |
@targetName("arrow2") def ~>[B](b: B): (A, B) = (a, b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment