Sunday, September 27, 2015

Functions in Swift -- IOS

//Functions is commonly used to group a series of statements together to achieve a specific objective

//To declare a function

func helloSwift(){

    print("hello Swift")

}

//To invoke a function

    helloSwift() // the word "hello swift" will be printed 


Function that Return value-

//To declare a function
 func helloSwift() -> String{

    return "hello Swift"
}

//To invoke a function and catch return in var "result"
var result = helloSwift()

//"result" is hello swift

print(result)

No comments:

Post a Comment