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

How to delete mapping? #570

Closed
stupidkitten opened this issue Dec 11, 2017 · 2 comments
Closed

How to delete mapping? #570

stupidkitten opened this issue Dec 11, 2017 · 2 comments

Comments

@stupidkitten
Copy link

Is there any way to delete a mapping?

For example I have the next struct:

test: public({
some_map: num256[bytes32],
variable: num
}[num])

In Solidity there is delete test[id];
I saw the solutions like test[id].variable = 0

But how to clean a mapping inside a mapping?

  • viper Version: 0.0.2
@fubuloubu
Copy link
Member

fubuloubu commented Dec 11, 2017

When you "delete" a mapping entry, you really just reset it to default values. Therefore a good solution would be an easier way to reset an entire struct (or other mapping member) to the default values for it's type signature using the standard syntax in Python:

del test[id]

@jacqueswww
Copy link
Contributor

jacqueswww commented Mar 26, 2018

Created #715 that basically solves this, so closing this issue ;)

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

3 participants