开发者

is foo += 1 considered functional?

Was thinking of creating a CONS function to create a list, but then realized that im not mutating any state with foo += 1, since its == foo = foo + 1 which is a new ob开发者_开发问答ject


The state is changed: the value referenced with the variable foo changes.

This is "not functional" in any pure sense. I might be tempted to call it "confusing" ;-)

Happy coding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜