Back to questions
JuniorTheoryCommon
What does the program print (lines separated by spaces)?
Task {
print("inside")
}
print("end")end
- Expecting
end inside: thinking the program waits for its tasks. It ends after the last line ofmain.swift, and a task nobody waited for withawait task.valuenever runs. - Expecting
inside end: readingTask { }as a call that runs its braces at once. The task runs separately, and the lines below it do not wait for it.
- How do you change the program so that it prints
insideas well? - Why does the same task run in an app that keeps working after this code?