Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sag333ar
Created August 19, 2015 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sag333ar/b8f8508bc38a1f073f53 to your computer and use it in GitHub Desktop.
Save sag333ar/b8f8508bc38a1f073f53 to your computer and use it in GitHub Desktop.
Exercise2 : String operation - Inserting values of variables in a string using \()
//: 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