DEV Community

Discussion on: Mastering Monadical Syntax in Ruby: A Practical Guide to Functional Elegance

Collapse
 
pimp_my_ruby profile image
Pimp My Ruby

Hi !

Returning a String, a Boolean, or an Integer do not give enough context. Using monad is a simple way to identify if it's a Success or a Failure, depending on your business logic.

There are other gems that help you to encapsulate the logic. The concept of encapsulating logic in order to give more context is not new.

The idea behind all that is to improve readability. I agree it's a new syntax. But once someone explained you / show you some example, it's very easily understandable.

Of course, you cannot just erase all the if in your code with using Monads, it is not THAT magic ahah. And for sure, I still use some return Failure() if xxx.

Let me know if you want to talk more about it, and maybe I can find some more complex codes example ?