Learning #SWIFT Day1

  1. Simple Values
    1. let constant
      1. let implicitInt = 70
      2. let explicitDouble: Double = 70
      3. let label = “The width is ”
        let width = 94
        let widthLabel = label + String(width)
    2. Array & Dictionary
      1. var shoppingList = [“a”, “b”, “c”];
      2. var Dict = [“key1″:”value1”, “key2″:”value2”];
  2. Control Flow
    1. if let name = optionalName { greeting = “hello, \(name)”}
    2. for i in 0..3 {}
    3. while n < 100 {}
  3. Functions & Closures
    1. func greet(name:String, day:String) -> String { return “hello \(name) on \(day)”}
    2. func makeIncrementer() -> (Int -> Int) {func addOne(number:Int) -> Int {return 1 + number} return addOne}
  4. Objects & Classes
    1. class Shape: BaseShape { var length:Double

init(length: Double, name: String) {

     self.length = length

     super.init(name:name)

                         }

  func area()-> Double {

 return length * length

}

override func simpleDescription() { return “simple Description for override.”}

     }

let test = Shape(length:5.2, name:”test”)

test.area()

test.simpleDescription()

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s