LearnNewsExamplesServices
Frontmatter
id1546
titleutil.Array: removeAdd() convenience method
stateClosed
labels
enhancement
assigneestobiu
createdAtMar 18, 2021, 12:39 AM
updatedAtMar 18, 2021, 12:41 AM
githubUrlhttps://github.com/neomjs/neo/issues/1546
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 18, 2021, 12:41 AM

util.Array: removeAdd() convenience method

Closed v8.1.0 enhancement
tobiu
tobiu commented on Mar 18, 2021, 12:39 AM

I am using remove() and add() in combination a lot, so a convenience method to combine the calls makes sense.

e.g.:

cls = dialog.cls;

NeoArray.remove(cls, me.currentTheme);
NeoArray.add(cls, theme);

dialog.cls = cls;

to keep it simple:

static removeAdd(arr, removeItems, addItems) {
    this.remove(arr, removeItems);
    this.add(arr, addItems);
}

I am not calling the method replace(), since this would indicate that items get replaced at its index and probably new items would only get added in case the item to replace exists.

feel free to open a new ticket in case you need a "real" replace() method.

tobiu added the enhancement label on Mar 18, 2021, 12:39 AM
tobiu assigned to @tobiu on Mar 18, 2021, 12:39 AM
tobiu referenced in commit 77e79a4 - "util.Array: removeAdd() convenience method #1546" on Mar 18, 2021, 12:41 AM
tobiu closed this issue on Mar 18, 2021, 12:41 AM