buzz-language / buzz

👨‍🚀 buzz, A small/lightweight statically typed scripting language
https://buzz-lang.dev
MIT License
1.15k stars 31 forks source link

feat(list/map): Added `list.clone` and `map.clone` #191

Closed giann closed 9 months ago

giann commented 9 months ago

closes #112

If user has to iterate and mutate list/map at the same time, it can use those functions:

[int] values = [1, 2, 3];

foreach (int i, int value in values.clone()) {
    if (value % 2 == 0) {
        values.remove(i);
    }
}