Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

27
  • 5
    Nullable<x> in C# is a similar concept but falls way short of being an implementation of the option pattern. The main reason is that in .NET System.Nullable is limited to value types. Commented Jul 13, 2012 at 17:47
  • 32
    +1 For the Option type. After getting familiar with Haskell's Maybe, nulls start looking weird... Commented Jul 13, 2012 at 17:53
  • 11
    Developer can make error anywhere, so instead of null pointer exception you will get empty option exception. How the latter is better than the former? Commented May 22, 2013 at 13:24
  • 9
    @greenoldman there is no such thing as "empty option exception". Try inserting NULL values into database columns defined as NOT NULL. Commented May 22, 2013 at 15:58
  • 41
    @greenoldman The problem with nulls is that anything can be null, and as a developer you have to be extra cautious. A String type isn't really a string. It's a String or Null type. Languages that fully adhere to the idea of option types disallow null values in their type system, giving a guarantee that if you define a type signature that requires a String (or anything else), it must have a value. The Option type is there to give a type-level representation of things that may or may not have a value, so you know where you must explicitly handle those situations. Commented Mar 13, 2014 at 15:01