filmov
tv
Default Values to Function Input Parameters | Julia Programming | Kovolff

Показать описание
Functions can take input parameters, which have default values.
i.e.
function aminor(user_age, user_name=””)
function_body
In this case user_name is by default an empty string.
You can call aminor either by just inputting the user age or both user age and user name
i.e.
aminor(“15”)
or
aminor(“15”, “Frank”)
Note: In Julia functions, parameters which have default values, come at the end of the list of input parameters.
i.e.
function aminor(user_name = “”, user_age)
function_body
Is wrong, as user_name should come after user_age, such as:
function aminor(user_age, user_name=””)
function_body
#julia #programming #learn
i.e.
function aminor(user_age, user_name=””)
function_body
In this case user_name is by default an empty string.
You can call aminor either by just inputting the user age or both user age and user name
i.e.
aminor(“15”)
or
aminor(“15”, “Frank”)
Note: In Julia functions, parameters which have default values, come at the end of the list of input parameters.
i.e.
function aminor(user_name = “”, user_age)
function_body
Is wrong, as user_name should come after user_age, such as:
function aminor(user_age, user_name=””)
function_body
#julia #programming #learn