Skip to content

Instantly share code, notes, and snippets.

@Centaur
Forked from mpilquist/example.scala
Last active August 29, 2015 14:26
Show Gist options
  • Save Centaur/0b54e2847cf83fe5bc28 to your computer and use it in GitHub Desktop.
Save Centaur/0b54e2847cf83fe5bc28 to your computer and use it in GitHub Desktop.
Using scala-reflect to desugar
scala> import scala.reflect.runtime.universe._
import scala.reflect.runtime.universe._
scala> showCode(reify {
| for{
| x <- 1 to 5
| _ = print("hi")
| } print(x)
| }.tree)
res1: String =
Predef.intWrapper(1).to(5).map(((x) => {
val x$1 = Predef.print("hi");
Tuple2.apply(x, x$1)
}))(IndexedSeq.canBuildFrom).foreach(((x$2) => (x$2: @unchecked) match {
case Tuple2((x @ _), _) => Predef.print(x)
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment