Sunday, February 12, 2017

Control Statement -Swift3 Coding Tutorial

Open Xcode.Click on Get Started with Playground.Name the playground.Then Create.

Then type following codes or copy it.

//Control Statement

var marks  = [10,45,30,70]

//for loop

for mark in marks
{
    if mark >  30
    {
        print("Pass \(mark)\n")
    }
    else
    {
        print("Fail \(mark)\n")
    }
    
}

//Iterative for loop

for num in 1...3
{
    print("Number \(num) \n")
}

//Switch Case 

let color = "Rainbow"

switch(color)
{
case "red":
    print("Red")

case "blue","yellow":
    print ("prime color")
    
case let colors where colors.hasPrefix("Rain"):
    print("Rainbow")
    
default :
    print("AnyColor")
}

//dictionary

var sports = ["cricket":["a","b","c"],"basketbal":["d","e","f"],"football":["g","h"]]

for (kind,names) in sports
{
    for name in names
    {
        print("\(kind)-\(name)\n")
    }
}
//while

var num = 1

while(num < 5 )
{
    print(num)
    num = num + 1
}

//it will reoeat while loop atleast once
repeat{
    
    print(num)
    
}while(num<5)


Saturday, February 11, 2017

Optional(?) - Swift3 Coding Tutorial

Open Xcode.Click on Get Started with Playground.Name the playground.Then Create.


Then type following codes or copy it.

Friday, February 10, 2017

Variable , Constant and DataType - Swift3 Coding Tutorial



Open Xcode.Click on Get Started with Playground.Name the playground.Then Create.

Then type following codes or copy it.

Thursday, September 22, 2016