Skip to content

Instantly share code, notes, and snippets.

@teamon
Created December 16, 2010 16:24

Revisions

  1. teamon revised this gist Dec 20, 2010. 1 changed file with 19 additions and 1 deletion.
    20 changes: 19 additions & 1 deletion FailDay.scala
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,22 @@ class X extends Actor {
    computeSomething (not react/receive) // FAIL, it blocks all actors
    }
    }
    }
    }



    def gimmeSize[A,B](m: Map[A,B]) = m.size

    val m = scala.collection.mutable.Map[String, Int]()

    gimmeSize(m)
    //<console>:8: error: type mismatch;
    // found : scala.collection.mutable.Map[String,Int]
    // required: Map[?,?]
    // s(m)

    // By default 'Map' is 'scala.collection.immutable.Map' and shared trait betwen
    // mutable and immutable map is 'scala.collection.Map'

    // Correct version:
    def gimmeSize[A,B](m: scala.collection.Map[A,B]) = m.size
  2. teamon revised this gist Dec 16, 2010. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions FailDay.scala
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,12 @@ class X extends Actor {
    }
    }
    }
    }

    class X extends Actor {
    def act {
    loop {
    computeSomething (not react/receive) // FAIL, it blocks all actors
    }
    }
    }
  3. teamon created this gist Dec 16, 2010.
    13 changes: 13 additions & 0 deletions FailDay.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    (0 to Int.MaxValue) == Range() // empty!

    class X extends Actor {
    def act {
    val a = actor {
    loop {
    receive { // FAIL, must use 'self.receive'
    case ...
    }
    }
    }
    }
    }