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

let mut for mutable values #26

Open
ammarbinfaisal opened this issue May 30, 2023 · 1 comment
Open

let mut for mutable values #26

ammarbinfaisal opened this issue May 30, 2023 · 1 comment

Comments

@ammarbinfaisal
Copy link
Owner

No description provided.

@ammarbinfaisal
Copy link
Owner Author

also mut would be used in function prototype to indicate whether the value is mutable or not. if it is primitive then the copy passed to the function would be mutated. if it is a reference then the original object would be mutated.

Example:

fun mutate(mp: mut map<int, bool>) {
    mp[1] = true
}

fun main() {
    let m = make(map<int, bool>)
    mutate(m)
    print(mp[1]) // true
}

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

1 participant