I know it doesn’t mean much to differentiate betwe...
# getting-started
u
I know it doesn’t mean much to differentiate between parameter and argument, but the official documentation mixes up the four and I’m curious to know what you guys prefer to call them. 🤔 1. default arguments 2. default parameters 3. default parameter values 4. default values
1️⃣ 6
2️⃣ 3
4️⃣ 2
3️⃣ 9
e
I usually say "(default) arguments". but "parameter" is also common, and then adding "value" helps to distinguish it from type parameters
j
There is a difference between arguments and parameters Arguments are the actual values that are passed to a function when it is called.
val foo = bar(10)
-
10
is an argument Parameters are placeholders defined in the function or method declaration.
fun bar(x: Int)
-
x
is an parameter I see they use a mix of all the "default X" https://kotlinlang.org/docs/functions.html#default-arguments Not totally sure if its correct to use the term
default arguments
but it's used quite wildly on the internet? Maybe all of those names are valid depending on the point of view?
3
👍 1
j
Parameters and arguments are different things, as described by Johan. So I think we should really not mix them up. For defaults, I would say "default parameters" doesn't make sense. A parameter is a variable. It can have a default value though, so "default parameter value" is the proper term IMO. "Default value" is the same, depending on whether it's clear from the context that we're talking about the default value of a parameter. "Default arguments" sounds slightly weird, because the default value is used when no argument is passed by the caller, so it's not really an argument. But it sort of makes sense when considering that we would use this value as argument when no argument is passed by the caller. At least it talks about arguments, which are values, so it's better than "default parameter".
3
💯 1
d
"Parameter" is the place that values can be passed into, and "Argument" is the actual value. Parameter declarations can include a "default value", which would be the value if no argument was supplied. I think "default value" or "parameter's default value" make sense. It is not "default parameter" though.
👍 1