Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain use of closures to overcome disallowed expressions at top level in Windowing System #746

Open
s0956678 opened this issue May 3, 2024 · 1 comment

Comments

@s0956678
Copy link

s0956678 commented May 3, 2024

In exercise "Windowing System", sub exercise 7, user is asked to create a Window and adjust its properties by using methods.

As Swift disallows expressions at the top level except for in the main file, the user cannot simply adjust the window properties at top level. The apparent solution is to use a closure that is immediately executed. While I was familiar with this concept from JS, it was not immediately obvious to me as a solution here. The possibility to immediately execute a closure is mentioned in passing in the Syllabus for "Closures" but it is not practiced in the corresponding learning exercise ("Double-Null0111: Closures Are Forever"). I think it is not immediately obvious for especially beginning Users that the sub-exercise in "Windowing System" can be resolved this way.

I would propose that this way of applying closures is explicitly practiced as such in "Double-Null0111: Closures Are Forever" and/or the Syllabus is adapted to make this application (the usages of closures to enable top-level execution code) explicit.

@gyenabubakar
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants