Change in Xcode 10 Playgrounds Variable Initialization change? Are Xcode 10 Playgrounds an interpreter?

梦想与她 提交于 2019-11-28 01:25:48

I hit this error. I had two different playgrounds up, one had the error and one did not. The issue was that "Automatically Run" was not set for my playground. To set the option, click on the play arrow at the top of the debug window in your playground and you will see the option to "Automatically Run", choose it.

Must be that Automatically Run mode is more like running an entire program, whereas manual run is not.

1) The error you now get if you do not initialize the let-declared constant is new as of Xcode 10, but only in the Swift REPL or playground, not if you compile the code (see below).

2) The Swift Playgrounds REPL (Read-Eval-Print-Loop) and an interpreter are almost but not quite the same thing. The REPL is an interactive text editor that reads your code statements, executes them, and prints the results, looping as you edit the text. As you make edits in a Playground, Xcode re-executes all the code in the editor over and over again, one line at a time as if you were typing in each line every time for the first time. This is different from an interpreter only in that an interpreter generally reads code from input files, interpreting and executing it one line at a time instead of compiling & linking it all to machine code first before execution begins.

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