Skip to content

Instantly share code, notes, and snippets.

@rcoh
Last active August 29, 2015 14:00

Revisions

  1. Russell revised this gist May 1, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion scalaclosures.scala
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,13 @@
    def inlineMeAgain[T](f: => T): T = {
    f
    }

    def inlineme(f: => Int): Int = {
    try {
    inlineMeAgain {
    return f
    }
    } catch safelyCatchThrowable {
    } catch {
    case ex: Throwable => 5
    }
    }
  2. Russell created this gist Apr 28, 2014.
    17 changes: 17 additions & 0 deletions scalaclosures.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    def inlineme(f: => Int): Int = {
    try {
    inlineMeAgain {
    return f
    }
    } catch safelyCatchThrowable {
    case ex: Throwable => 5
    }
    }

    def doStuff {
    val res = inlineme {
    10
    }
    println("we got: " + res + ". should be 10")
    }
    doStuff