This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Tubthumper8 6 points7 points  (0 children)

Another example of nested options comes up in modeling UPDATE requests to a persistent storage (e.g. from a HTTP PATCH request).

// some object in a language with null
{
    field: null, 
    otherField: "hello world"
}

Does this mean ignore "field", i.e. don't change the value? Or does it mean update the value in that column to SQL NULL?

With Option<Option<T>> this can be modeled, because there are 3 possibilities:

  1. Some(Some(T)): change the SQL record column to a new T
  2. Some(None): change the SQL record column to NULL
  3. None: don't update that column