Deep_Dev
article thumbnail

πŸ“– Day 08  : ν•¨μˆ˜ λ§€κ°œλ³€μˆ˜ 이름 

 

 

πŸ“Œ ν•¨μˆ˜ λ§€κ°œλ³€μˆ˜ 이름 μ„€μ •

func myFunction(name : String) -> String{
    return "μ•ˆλ…•ν•˜μ„Έμš”?! \(name) μž…λ‹ˆλ‹€!"
}

myFunction(name:"Deep_Lee")
// >>> μ•ˆλ…•ν•˜μ„Έμš”?! Deep_Leeμž…λ‹ˆλ‹€!

πŸ’¬ name : λ§€κ°œλ³€μˆ˜ 이름, ->λŠ” String을 λ°˜ν™˜ν•œλ‹€λŠ” 뜻

 

 

πŸ“Œ 전달 인자 λ ˆμ΄λΈ”

func myFunctionSecond(myName name:String)-> String{
    return "μ•ˆλ…•ν•˜μ„Έμš”?! \(name) μž…λ‹ˆλ‹€!"
}

myFunctionSecond(with : "μŠ€μœ„ν”„νŠΈ")
// >>> μ•ˆλ…•ν•˜μ„Έμš”?! μŠ€μœ„ν”„νŠΈμž…λ‹ˆλ‹€!

πŸ’¬  같은 λ©”μ†Œλ“œμ΄μ§€λ§Œ 이름을 λ°”κΏ€ 수 μžˆλ‹€.

πŸ’¬ withλΌλŠ” μ „λ‹¬μΈμž λ ˆμ΄λΈ”μ΄ 있으며, nameμ΄λΌλŠ” λ§€κ°œλ³€μˆ˜ 이름이 μžˆλŠ” ν•¨μˆ˜μ΄λ‹€.

 

 

πŸ“Œ 전달 인자 λ ˆμ΄λΈ” μ‚¬μš©ν•˜κ³  싢지 μ•Šλ‹€λ©΄

  • μ™€μΌλ“œ μΉ΄λ“œ μ‹λ³„μž ( _ ) μ‚¬μš©
func myFunctionThird(_ name:String) -> String{
    return "μ•ˆλ…•ν•˜μ„Έμš”?! \(name) μž…λ‹ˆλ‹€!"
}

myFunctionThird("iOS")
// >>> μ•ˆλ…•ν•˜μ„Έμš”?! iOS μž…λ‹ˆλ‹€!

 

 

 

<μ „μ²΄μ½”λ“œ>

좜λ ₯κ²°κ³Ό

>>> μ•ˆλ…•ν•˜μ„Έμš”?! μ •λŒ€λ¦¬ μž…λ‹ˆλ‹€!
>>> μ•ˆλ…•ν•˜μ„Έμš”?! κ°œλ°œν•˜λŠ” μ •λŒ€λ¦¬ μž…λ‹ˆλ‹€!
>>> μ•ˆλ…•ν•˜μ„Έμš”?! κ°œλ°œν•˜λŠ” μ •λŒ€λ¦¬ μž…λ‹ˆλ‹€!

 

 

 

 

'🍎 iOS > κΈ°μ΄ˆλ¬Έλ²•' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

[Swift]10 : Closure  (0) 2022.12.06
[Swift]09 : Generic  (0) 2022.12.06
[Swift]07 : Property Observer  (0) 2022.12.03
[Swift]06 : Class vs Struct  (0) 2022.12.03
[Swift]05 : Unwrap μ˜΅μ…”λ„λ³€μˆ˜  (0) 2022.12.03