-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Having to encode this behaviour at every call site is tedious. It makes a lot of sense to just have the method available on list itself.
- Loading branch information
Showing
4 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var a = [1, 2, 3] | ||
a.remove(2) | ||
System.print(a) // expect: [1, 3] | ||
|
||
var b = [1, 2, 3] | ||
b.remove(1) | ||
System.print(b) // expect: [2, 3] | ||
|
||
var c = [1, 2, 3] | ||
c.remove(3) | ||
System.print(c) // expect: [1, 2] | ||
|
||
// Return the removed value. | ||
System.print([3, 4, 5].remove(4)) // expect: 4 | ||
System.print([3, 4, 5].remove(5)) // expect: 5 | ||
|
||
// Return null when not found | ||
System.print([1, 2, 3].remove(8)) // expect: null |