Discover how to execute Swift code in the command line. Additionally, learn how to execute Swift while debugging Xcode projects using interactive REPL sessions.
- Although I use playgrounds throughout the course,…there is another interactive sandbox environment…you can use to experiment with swift code.…A REPL,…or read eval print loop,…can be initiated in a command line environment,…such as from the terminal app,…or in an xcode project console…during a paused debug session.…To start a REPL session using terminal,…which I'll launch by using spotlight,…but you can also find it…in the applications utilities folder,…type swift at the command prompt,…and press return.…A welcome message will be displayed indicating the version…of swift you are using,…and a tip on how to get help.…
The prompt now displays a line number…and a right angle bracket,…indicating that it's ready for you to enter some swift code.…So, I'll create a string.…And press return to execute my code.…And the REPL will execute and display the results.…Code entered into a REPL is recorded…in the REPL history,…even across sessions.…And you can use the up and down arrows on your keyboard…to cycle through history.…I'll change the string assignment to our str variable…
Learn how to write code, understand Swift's key concepts and best practices, and strengthen your programming problem-solving skills. Instructor Scott Gardner teaches the fundamentals, so you'll be prepared to develop applications for iOS, macOS, and other platforms. Completing this course will enable you to not only write first-class code, but to think like a Swift developer.
- Creating playgrounds
- Defining variables and constants
- Working with characters and strings
- Working with collections and groups
- Using operators and defining custom operators
- Controlling program flow
- Defining functions and closures
- Working with classes, structures, and enumerations
- Adopting protocols
Skill Level Beginner
1. Get Started
2. Variables and Constants
3. Characters and Strings
4. Collections and Tuples
6. Control Flow
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.