scalapuzzlers/scalapuzzlers.github.com — pull request #80 by som-snytt (2013-07-06 07:09:56+00:00)
Title: 038 Sharp Corner Cases

When does A not match A? It's a corner case.

My first draft was simpler, see below.

I juiced it slightly because of the "baby announcement" theme, hopes for the "future" and all that. "It's a 7!" doesn't mean anything.

But having two cases is harder to reason about and suggests traps about the basic mechanics of the pattern match (case order, whatever), instead of how ClassTag is used. WDYT?

```
class C[A: ClassTag] {
def announce(f: Future[A]) = f onSuccess {
case a: A => Console println s"It's a $a!"
}
}
```