//code1
func callName (_ name : String) {
print("\(name)님 환영합니다!")
}
callName("jdh")
//code2
func callName (_ name : String) {
print("\(name)님 환영합니다!")
}
let name = ["jdh","lhh","yyk","jjh","lky"]
for i in 0..<name.count {
callName(name[i])
}
//code3-1
func callName (_ num : Int)-> Int {
return num
}
let name = ["jdh","lhh","yyk","jjh","lky"]
print("\(name[callName(3)])님 환영합니다!")
//code3-2
func callName (_ name : [String], _ num : Int) {
print("\(name[num])님 환영합니다!")
}
let name = ["jdh","lhh","yyk","jjh","lky"]
callName(name,3)
//code4
func callName (_ name : [String], _ num : Int)-> String {
return name[num]
}
let name = ["jdh","lhh","yyk","jjh","lky"]
print("\(callName(name,3))님 환영합니다!")
//code5
func callName (_ name : [String], _ num : Int)-> (memberName:String,index:Int) {
return (name[num],num)
}
let name = ["jdh","lhh","yyk","jjh","lky"]
var myTuple : (memberName :String, index:Int) = callName(name,3)
print("\(myTuple.memberName)님 환영합니다!")
//code6
func callName (_ name : String...) {
for i in name {
print("\(i)님 환영합니다!")
}
}
let name = ["jdh","lhh","yyk","jjh","lky"]
callName(name[0],name[1],name[2],name[3],name[4])
'PROGRAMMING CODE > SWIFT' 카테고리의 다른 글
[Swift] 기초 예제 5 (딕셔너리) (0) | 2023.06.08 |
---|---|
[Swift] 기초 예제 4 (클래스, 복사) (0) | 2023.06.04 |
[Swift] 기초 예제 1 (0) | 2023.05.31 |
[Swift] 키체인 오류 (0) | 2022.07.18 |
[Swift] Signing for "appname" requires a development team. Select... 오류 해결 (0) | 2022.07.15 |