We have a = [ ] to clear an array. It's very natural to also have a = { } to clear a map.
fn main() {
mut a := {'one':1}
a = {}
}
Now the above code, for example, gives V error - type map_string_int is private.
Be careful, a = [] doesn't clear the array, it creates a new one (and therefore requires a new memory allocation). a.clear() really removes the items from the array.
This isn't really a feature request, and more a bug report, it should already work.
Most helpful comment
Be careful,
a = []doesn't clear the array, it creates a new one (and therefore requires a new memory allocation).a.clear()really removes the items from the array.This isn't really a feature request, and more a bug report, it should already work.