Monad equivalent in Ruby

后端 未结 4 1524
野性不改
野性不改 2021-01-30 03:31

What would an equivalent construct of a monad be in Ruby?

4条回答
  •  遇见更好的自我
    2021-01-30 03:59

    Monads are not language constructs. They're just types that implement a particular interface, and since Ruby is dynamically typed, any class that implement something like collect in arrays, a join method (like flatten but only flattens one level), and a constructor that can wrap anything, is a monad.

提交回复
热议问题