Swift Basics: [Advanced - Functions] Default Parameters & Argument Labels
⚙️ Default Parameter Values A default parameter value allows a parameter to automatically assume a specific value if no argument is passed in when the function is called. To declare a default parameter, simply specify the type after the parameter name and assign the default value to it. Tip: It is highly recommended to place parameters with default values at the very end of your parameter list. Swift // Specify the type after the parameter name and assign the default value func functionName ( param1Name : Param1Type , param2Name : Param2Type = DefaultValue ...) -> ReturnType { // Function implementation return returnValue } Let's look at an example. Below, we've set the default parameter value for me to "Jeamin" . Swift // A default value is assigned after the 'me: String' parameter type func greeting ( friend : String , me : String = "Jeamin" ) { print ( "Hello \(friend) ! I am \(me) ." ) } Now let's call t...