[Swift] function 1-4

iOS 2015. 7. 23. 23:57
반응형




import Foundation


func joinString(#strings: [String]) -> String {

    var returnStr = ""

    for str in strings {

        returnStr += str

    }

    return returnStr

}


func joinString(#strings: String...)->String{

    return joinString(strings: strings)

}


var arrayOfStrings = ["I", "am", "an", "Array"]

joinString(strings: arrayOfStrings)

joinString(strings: "I", "am", "variadic")


func incrementNumnber(inout #number: Int, increment: Int = 1){

    number += increment

}


var ourInt = 1

incrementNumnber(number: &ourInt)

ourInt


incrementNumnber(number: &ourInt, increment: 10)

ourInt


반응형

'iOS' 카테고리의 다른 글

Linking is broken for static library (since Xcode6)  (0) 2015.07.30
[Swift] Class 1-1 (inheritance, referance copy)  (0) 2015.07.25
[Swift] function 1-3  (0) 2015.07.23
[Swift] function 1-2  (0) 2015.07.23
[Swift] function 1-1  (0) 2015.07.23
: