Skip to content

Instantly share code, notes, and snippets.

@wfaler
Created January 18, 2011 00:33
Show Gist options
  • Select an option

  • Save wfaler/783786 to your computer and use it in GitHub Desktop.

Select an option

Save wfaler/783786 to your computer and use it in GitHub Desktop.
OptionMapper.scala
def `GET /widgets/:id`(widget: Option[Widget]) = render(widget)
@Synesso

Synesso commented Jan 26, 2011

Copy link
Copy Markdown

Not quite idiomatic Scala. How about:
def render(maybeWidget: Option[Widget])
so that clients might simply call:
render(widget)
whether it be None or Some.

@wfaler

wfaler commented Jan 26, 2011

Copy link
Copy Markdown
Author

Hi, thanks for the pointer.
This was actually fixed in the last few days (though not yet in the example app, which lags a little behind) - there was a bug in Bowler core where rendering null or None resulted in an exception when it shouldn't - now it checks for options and unwraps them for rendering if it is a "Some".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment