Writing your own functions - structs
In this final exercise on structs, you are going to modify a pre-defined structure using a custom constructor.
You have been provided with a custom type to store the details of each employee at our company, and this a mutable struct so that the values within the instance can be modified. Our company only has one office in Sydney, so let's set the location field to Sydney by default when creating a new instance.
After this, you need to write a custom function to increment the age field when it is the birthday of an employee.
Den här övningen är en del av kursen
Intermediate Julia
Interaktiv övning med praktiskt arbete
Testa den här övningen genom att slutföra den här exempelkoden.
mutable struct Employee
name::String
location::String
age::Int
# Create a function that defaults the location to "Sydney"
function ____(name, ____)
____(____, "Sydney", ____)
end
end