We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've written a little example about a bank user and its account.
// Example: addMoney(#user(name: "coco", age: 10, account: #account(10, 100)), 50) type User :: #nil or #user(name: String, age: Int, account: Account) type Account :: #empty or #account(_ interest: Int, _ money: Int) func addMoney(_ user: User, _ moneyAdd: Int) -> User :: match(user) with #nil :: #nil with #user(name: let nom , age: let age, account: let account) :: match(account) // with #empty :: // #nil with #account(let interest, let money) :: #user(name: nom, age: age, account: #account(interest, money + moneyAdd))
The code above works if I comment:
with #empty :: #nil
Otherwise, I have this error:
l.29:c.5: type error: type '#empty' doesn't match '#account(_: $8, _: $9)': match(account)
In Account, I've defined two cases, but the #empty case isn't recognize. I've tested a case with only Account but everything works:
#empty
// foo(account: #account(10,10)) func foo(account: Account) -> User :: match(account) with #empty :: #nil with #account(let interest, let money) :: #nil
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I've written a little example about a bank user and its account.
The code above works if I comment:
Otherwise, I have this error:
In Account, I've defined two cases, but the
#empty
case isn't recognize.I've tested a case with only Account but everything works:
The text was updated successfully, but these errors were encountered: