Skip to content

Commit

Permalink
add copy and copyWithout to Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
nicovio committed Jul 24, 2019
1 parent a705fe3 commit 7731850
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions org.uqbar.project.wollok.lib/src/wollok/lang.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,20 @@ class Collection {
return copy
}

method copyWith(element) {
const copy = self.newInstance()
copy.addAll(self)
copy.add(element)
return copy
}

method copyWithout(element) {
const copy = self.newInstance()
copy.addAll(self)
copy.remove(element)
return copy
}

/**
* Answers a new List that contains the elements of self collection
* sorted by a criteria given by a closure. The closure receives two objects
Expand Down

0 comments on commit 7731850

Please sign in to comment.