Skip to content

Commit fe05af1

Browse files
committed
..
1 parent f97258e commit fe05af1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cpp.fp/optional/optional.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ int main(int argc, char* argv[])
2424
vector_opt<string> v = { "1234", "15 foo", "bar", "42", "5000", " 5" };
2525

2626
// NOTICE
27-
// an operation which changes stored variable -> transform
28-
// an operation which could itself fail -> and_then
27+
// the functions inside and_then should an optional<T> as a result,
28+
// the transform re-box the output of function into an optional<T>
2929
auto filter = [](auto&& o) {
30-
return o.and_then(to_int) // flatmap from str to int
30+
return o.and_then(to_int) // flatmap from str to int
3131
.transform([](int n) { return n + 1; })
3232
.transform([](int n) { return to_string(n); })
3333
.or_else ([] { return optional("null"s); });

0 commit comments

Comments
 (0)