You probably guessed it - this is a piece of code from the sample app for the video, written in JavaScript, but it could just as well be valid Swift code. In fact, a JavaScript linter would probably scold me for not using ;
at the end of each statement…
The evolution of Swift and JavaScript couldn’t be more different, though - JavaScript is a language that has to walk a fine line of browser compatibility, whereas early versions of Swift seemed to follow the principle of “move fast, and break things”. You can still painfully see the results of this process when looking as StackOverflow answers that provide solutions for several versions of Swift, because of slight differences between language versions.
I am happy Swift has reached a state of relative stability now, while still being able to add new concepts such as async/await.
I hope you enjoy this fifth edition of
Not Only Swift Weekly - if you do, please share it with a friend. And as always, feel free to share your feedback
with me!
Thanks for reading!
Peter