Permalink
Browse files

misc fixes

  • Loading branch information...
lihaoyi committed Nov 30, 2016
1 parent 0d12fd1 commit f961c1fa7573e66b7a0d31f6a73bb49941d2ef1f
Showing with 6 additions and 6 deletions.
  1. +6 −6 post/16 - Old Design Patterns in Scala.md
@@ -358,7 +358,7 @@ to the end of this chain. - Wikipedia
Using an [example from Wikipedia](https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern#Example),
which models a chain of individuals in an organization who can approve a
purchase (depending on price) you first define a bunch of `PurchasePower`
purchase (depending on price), you first define a bunch of `PurchasePower`
classes:

```java
@@ -454,15 +454,15 @@ val prettyPrintFailedHandler: PartialFunction[Throwable, Res.Failing] = {
case Ex(e: ThreadDeath) => interrupted(e)
}
val userCodeExceptionHandler: PartialFunction[Throwable, Res.Failing] = {
val simpleFailureHandler: PartialFunction[Throwable, Res.Failing] = {
case Ex(_: InvEx, e: ThreadDeath) => interrupted(e)
case Ex(_: InvEx, _: InitEx, userEx@_*) => Res.Exception(userEx(0), "")
case Ex(_: InvEx, userEx@_*) => Res.Exception(userEx(0), "")
case Ex(userEx@_*) => Res.Exception(userEx(0), "")
}
val userCodeExceptionHandler = {
exitHandler.orElse(prettyPrintFailedHandler).orElse(userCodeExceptionHandler)
exitHandler.orElse(prettyPrintFailedHandler).orElse(simpleFailureHandler)
}
```

@@ -678,10 +678,10 @@ Which in Java would be something like
```scala
Frag frag = new HtmlFrag({},
new HtmlFrag(
new Header1Frag({new Attr("id", "my-title")},
new Header1Frag(new Attr[]{new Attr("id", "my-title")},
new StringFrag("Hello")
),
new ParagraphFrag({new Attr("background-color", "red")},
new ParagraphFrag(new Attr[]{new Attr("background-color", "red")},
new StringFrag("Hello")
)
)
@@ -864,4 +864,4 @@ significant reduction in verbosity, work about the same as they always have.
This post only looks at how historical "Design Patterns" apply to the Scala
programming language, and does not look at what new design patterns have
emerged that are unique to the Scala language. That would be a topic for a
future post!
future post!

0 comments on commit f961c1f

Please sign in to comment.