Functional programming: state vs. reassignment

后端 未结 4 1631
星月不相逢
星月不相逢 2020-12-13 07:44

I need help getting my head around the difference between my current OOP notion of state, and the way it would be done in a functional language like Haskell or Clojure.

4条回答
  •  -上瘾入骨i
    2020-12-13 08:04

    Look at Haskell, which is a pure functional language—it has no re-assignment whatsoever, as well as no other side-effects: in order to do IO, in the IO monad construct it actually replaces the RealWorld with a new instance of the world that has, e.g., new text displayed in the console.

提交回复
热议问题