Created
August 19, 2015 10:03
-
-
Save sag333ar/b8f8508bc38a1f073f53 to your computer and use it in GitHub Desktop.
Exercise2 : String operation - Inserting values of variables in a string using \()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
// The Swift Programming Language | |
// iBook Page 6 (13" screen display with full screen) | |
// Basic string operations | |
import UIKit | |
// declare two variables | |
let apples = 3 | |
let oranges = 5 | |
// Example 1. using \() for adding values of variables within string | |
let appleSummary = "I have \(apples) apples." | |
// Example 2. using \() for adding values after an operation | |
let fruitSummary = "I have \(apples + oranges) pieces of fruites." | |
// Example 3. | |
// use \() to include a floating point & string to include someones name. | |
let todaysTemp = 37.5 | |
let today = "Monday" | |
let greetings = "Hello ! It's \(today) morning & temperature is \(todaysTemp)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment