All of them have different semantics, so in your case none of them.
map
applies some function to the value inside Option
, if it exists (Some
, not None
). Basically this is how you safely work with Options
, appling function on some null
value is dangeroues, cause it can throw NPE, but in case with Option it just returns None.
getOrElse
simply returns either it's value or default one (which you provide as an argument). It won't do anything with the value inside the Option
, you can just extract it, if you have Some
, or return a default one, in case of None.
and match
approach i'd say is a combination of two, cause you can apply some computation on the values and extract it from the Option