Skip to content

Abcmsaj/swift-firstTask-playground-swift-intro-000

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Variables

Oscar Wilde

Be yourself; everyone else is already taken. -Oscar Wilde

Overview

This Playgrounds lab, you'll create and print variables and constants that represent string and integer types.

Learning Objectives

  • Create variables and constants using let and var.
  • Use the print() function to print their String types to the console.
  • Create variables of type String and Int.
  • Create variables using type inference and type annotations.
  • Use string interpolation to print out String literals to the console.

Instructions

This is your first lab. Some labs require that you open up Xcode, other labs ask that you open up the playground file. What does that mean?

We introduced you to Xcode earlier in this course and we'll cover it in more detail in subsequent lessons. For now, know that this lab is asking that you open up a playground file, and we'll walk you through those steps. The playground file has no tests in it.

First things first, you should clone down this repository. If you aren't familiar with how to do that or the process of submitting labs, review the earlier lesson that covered this.

After cloning down this project, you should locate the directory in Terminal or locating it through finder.

Example of locating the directory in Finder:

dir

Example of locating the directory in Terminal:

dir2

Open up the MyPlayground.playground file. After doing so, you should see the following:

play

If you see something like this instead, then you need to make sure Render Documentation is checked.

instead

You can check off the Render Documentation by opening up the Utilities pane (top right box thing) and then check it off like so:

checks

Here's how you should be answering these various questions. We like to delete where it states

// write your code here

Then replace that section with what you think the answer is.. like so:

answer

What exactly is a Playground file? A playground is an interactive Swift coding environment that evaluates each statement and displays results as updates are made, without the need to create project. Here's an example:

play

Notice how in the right pane, the playground file is able to compile and run this code while I'm typing it in. That's awesome and makes it a really great tool to learn how to code. As you move forward in your "learning how to program" career, if you're ever challenged with a topic or want to brush up on some material, create your own playground by launching Xcode and just start writing some code!

Now.. move forward and complete this lab! After you're done, make sure you save your changes and follow the correct steps to making a Pull Request. Review the earlier lesson that covered this process if you need a refresher.

Good luck.

luck

View this lesson on Learn.co

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%