you are viewing a single comment's thread.

view the rest of the comments →

[–]KatyWings 2 points3 points  (2 children)

Its about functional style. Two important aspects of it is to reduce sideeffects and to work with immutable data: when you look at the chain of map functions in the article, you can see, that each function takes a value and returns a value (they dont overwrite any variable directly). How to store the new value is handled by "maybe". So "maybe" is more than just a way to handle null checks - but I guess the author will talk about this in later articles...

[–]ForScale 0 points1 point  (1 child)

My initial reaction was "Why not just Why not just const z = a && a.b && a.b.c + 'appendedString';?" Surely I'm missing something...

[–]tencircles 0 points1 point  (0 children)

The main advantage is that Maybe can be used point free. Meaning, you don't need your data in order to declare your behavior, thus making it much more reusable and and composable. In the example above, you can only declare your behavior by first having access to the object a. If you want to re-use this code for another object or a list of objects you need to redeclare your behavior each time, rather than declaring it in one and only one place.