Positional parameters (or positional arguments) refer to the default mechanism of passing arguments to a function, method, or constructor where the mapping between the provided argument and the receiving parameter is determined strictly by their sequential order (index) in the function signature. The compiler binds the first argument to the first parameter, the second to the second, and so forth, evaluating them from left to right.Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
Syntax and Mechanics
When invoking a function using positional arguments, the types of the provided arguments must be assignable to (i.e., subtypes of) the declared parameter types at the corresponding indices.- Index
0("127.0.0.1") binds tohost: CharSequence - Index
1(443) binds toport: Number - Index
2(true) binds tosecure: Boolean
Rules and Constraints
Strict Left-to-Right Binding Positional arguments are always consumed strictly from left to right. You cannot skip a parameter positionally. If a function defines default values for its parameters, positional arguments will overwrite those defaults in sequential order.timeout and retries and only provide a value for log, positional arguments cannot be used; named arguments are required.
Mixing with Named Arguments
Kotlin allows mixing positional and named arguments in a single invocation. When doing so, positional arguments must maintain their exact sequential alignment with the function signature. Prior to Kotlin 1.4, all positional arguments had to precede the first named argument. As of Kotlin 1.4+, a named argument can appear anywhere in the sequence, provided the subsequent positional arguments remain in their correct absolute index slots.
vararg
When a function signature includes a vararg (variable number of arguments) parameter, positional arguments will be continuously absorbed by the vararg until the argument list ends or a named argument is encountered. If the vararg is not the final parameter in the signature, any parameters declared after it cannot be assigned using positional arguments.
Master Kotlin with Deep Grasping Methodology!Learn More





