nosewheelie

Technology, mountain biking, politics & music.

scala.Option Cheat Sheet

without comments

Tony has a nice post on using Scala’s Option type:

Many people who are coming in to Scala first encounter the Option type, which may be thought of (among other things) as a type-safe null. They also encounter pattern matching as both a new and (relatively) powerful concept, but also one that is easy to understand. This leads to quite a lot of use of pattern matching and often excessively so in what I have observed.

Particularly with a type as trivial as Option, it is almost always possible to do away with pattern matching by using a higher-order function. Use of this function is typically preferred over pattern matching as tighter code.

Source: scala.Option Cheat Sheet.

Written by Tom Adams

January 17th, 2008 at 10:23 am

Posted in Scala

Leave a Reply