3/22 매개변수 및 인수

justyoon·2023년 3월 22일
0

AI5 Python/Django

목록 보기
9/31

What's the difference between Parameter and Argument?

Parameter(매개변수)Argument(인수,인자)는 프로그래밍에서 자주 사용되는 용어이지만 협업/설명시 정확한 개념을 모른 체 다양한 단어를 혼용하고 있다. 개인적으로 영어로 이해했을때 더 쉬웠던 주제여서 영어로 정리함.

Q: The general consensus seems to be that it's OK to use these terms interchangeably in a team environment. Except perhaps when you're defining the precise terminology; then you can also use "formal argument/parameter" and "actual argument/parameter" to disambiguate.
A1: A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method's parameters.
public void MyMethod(string myParam) { }

...

string myArg1 = "this is my argument";
myClass.MyMethod(myArg1);
A2: A parameter is a variable in the declaration of the function.

An argument is the actual value of the variable that gets passed to the function.

logic

When you call a method, you pass in arguments.
When you define the method, you are defining the parameters that will take the arguments from the method / function call.

argument - an 	independent variable associated with a function and determining the value of the function.
parameter - a limit or boundary that defines the scope of a particular process or activity

Conclusion :

So, It would be expressed in various explains, but as follows

  • A parameter is the initial value determined by a programmer when defining a function, whereas a variable that receives a value later from the user during runtime is called an argument

Reference :

related : formal parameter, actual parameter

profile
with gratitude, optimism is sustainable

0개의 댓글