์ƒˆ์†Œ์‹

๐Ÿ“ฑ iOS/-- Swift 5

๋งค๊ฐœ๋ณ€์ˆ˜ (Parameter), ์ธ์ž (Argument)์˜ ์ฐจ์ด

  • -

๋งค๊ฐœ๋ณ€์ˆ˜์™€ ์ „๋‹ฌ์ธ์ž

๋งค๊ฐœ๋ณ€์ˆ˜(Parameter) ์ „๋‹ฌ์ธ์ž(argument)

ํŒŒ๋ผ๋ฏธํ„ฐ์™€ ์•„๊ทœ๋จผํŠธ๋ฅผ ํ˜ผ์šฉํ•ด์„œ ์“ฐ์ด๊ธฐ๋„ ํ•˜์ง€๋งŒ, ์ •ํ™•ํ•œ ์˜๋ฏธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•˜๋Š” ๋ถ€๋ถ„์— ์žˆ๋Š” ๋ณ€์ˆ˜๋ฅผ ์˜๋ฏธํ•˜๊ณ , ์ „๋‹ฌ์ธ์ž๋Š” ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ• ๋•Œ ์ „๋‹ฌ๋˜๋Š” ๊ฐ’์œผ๋กœ ๋ณด์•„์•ผ ํ•œ๋‹ค.

  • ๋งค๊ฐœ๋ณ€์ˆ˜ == parameter == ๋ณ€์ˆ˜

  • ์ „๋‹ฌ์ธ์ž== argument== ๊ฐ’

func greet(person: String) -> String{
  let greeting = "Hello, " + person + "!"
  return greeting
}
print(greet(person: "JY"))
>>> Hello, JY!

์˜ˆ๋ฅผ๋“ค์–ด ์œ„ ์ฝ”๋“œ์—์„œ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” person์ด ๋˜๊ณ , ์•„๊ทœ๋จผํŠธ๋Š” JY๊ฐ€ ๋œ๋‹ค.

Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.