Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: setfield! immutable struct of type MyTime cannot be changed #35

Open
WenjieZ opened this issue Jan 8, 2020 · 1 comment
Open

Comments

@WenjieZ
Copy link
Contributor

WenjieZ commented Jan 8, 2020

In Chapter 16, the Modifiers section, you have the following code:

function increment!(time, seconds)
    time.second += seconds
    if time.second >= 60
        time.second -= 60
        time.minute += 1
    end
    if time.minute >= 60
        time.minute -= 60
        time.hour += 1
    end
end

This won't work because MyTime is previously defined as an immutable struct.

@BenLauwens
Copy link
Owner

Good remark! I have to introduce a mutable MyTime type;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants