Undefined behavior, or: Does Swift have sequence points?

无人久伴 提交于 2019-11-30 14:13:59

The question was answered by Apple developer and Swift designer Chris Lattner in the Apple Developer Forum https://forums.developer.apple.com/thread/20001#63783:

Yes, the result of that expression will always be 4. Swift evaluates expressions left to right, it isn't undefined or implementation defined behavior like C.

Chris also added:

That said, if you write code like that, someone trying to maintain it will probably not be very happy with you

Agreed! It was meant as an extreme example to demonstrate the problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!