开发者

is foo += 1 considered functional?

开发者 https://www.devze.com 2023-03-07 22:29 出处:网络
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开发者_开发问答jectThe state is ch

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

精彩评论

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