To extract values from an option type (no matter what it contains), you need to use the Some <...>
pattern where <...>
is a nested pattern that is can give name to the value (if you want a single variable containing the tuple) or decompose it further (if you want three separate variables):
let a,b,c =
match aRow with
| Some(a, b, c) -> a, b, c
| None -> failwith "Cannot find a row"
Alternatively, you can just use the built-in Option.get
function:
let a,b,c = Option.get aRow
Your code relies on a trick - that headOrDefault
returns null
if there is no row - which will work, because null
is the internal representation of None
. But you could also use an extension that adds headOrNone
to make the code a bit nicer.