@@ -66,7 +66,7 @@ Option.forEach(None, x => Console.log(x)) // returns ()
66
66
let forEach: (option<'a>, 'a => unit) => unit
67
67
68
68
/**
69
- `getExn(opt)` raises an Error in case `None` is provided .
69
+ `getExn(opt)` returns `value` if `opt` is `Some(value)`, otherwise raises an exception .
70
70
71
71
```rescript
72
72
Option.getExn(Some(3)) // 3
@@ -96,8 +96,7 @@ Option.getUnsafe(None) // Raises an error
96
96
external getUnsafe: option<'a> => 'a = "%identity"
97
97
98
98
/**
99
- `mapWithDefault(opt, default, f)` applies `f` to `opt`, if `opt` is `None`, then
100
- `f` return `default`, otherwise return that value applied with `f`.
99
+ `mapWithDefault(opt, default, f)` returns `Some(f(value))` if `opt` is `Some(value)`, otherwise `default`.
101
100
102
101
## Examples
103
102
@@ -112,8 +111,7 @@ noneValue->Option.mapWithDefault(0, x => x + 5) // 0
112
111
let mapWithDefault: (option<'a>, 'b, 'a => 'b) => 'b
113
112
114
113
/**
115
- `map(opt f)` applies `f` to `opt`, if `opt` is `Some(value)` this returns
116
- `f(value)`, otherwise it returns `None`.
114
+ `map(opt, f)` returns `Some(f(value))` if `opt` is `Some(value)`, otherwise `None`.
117
115
118
116
## Examples
119
117
@@ -125,8 +123,7 @@ Option.map(None, x => x * x) // None
125
123
let map: (option<'a>, 'a => 'b) => option<'b>
126
124
127
125
/**
128
- `flatMap(opt, f)` returns `f` applied to `opt` if `opt` is `Some(value)`,
129
- otherwise `None`. The function `f` must have a return type of `option<'b>`.
126
+ `flatMap(opt, f)` returns `f(value)` if `opt` is `Some(value)`, otherwise `None`.
130
127
131
128
## Examples
132
129
@@ -146,8 +143,7 @@ Option.flatMap(None, addIfAboveOne) // None
146
143
let flatMap: (option<'a>, 'a => option<'b>) => option<'b>
147
144
148
145
/**
149
- `getWithDefault(opt, default)` returns `value` if `opt` is `Some(value)`,
150
- otherwise return `default` if `opt` is `None`.
146
+ `getWithDefault(opt, default)` returns `value` if `opt` is `Some(value)`, otherwise `default`.
151
147
152
148
## Examples
153
149
0 commit comments