F # - Convert Int option to Int64 option

Is there a better way how to do this?

let intOption = Some(123) 
let longOption = match intOption with
                   | Some x -> Some(int64 x )
                   | None   -> None

      

I need to convert option of int

to option of int64

.

+3


source to share


2 answers


Option.map

does exactly what you need.



intOption |> Option.map int64

      

+3


source


The function you are looking for is Option.map

:



let longOption = Option.map int64 intOption

      

+3


source







All Articles