add in
, contains
, and MembershipTestable
#615
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add an
in
operator that tests membership as in many other languages (e.g., Python, Kotlin, Rust). The operator combination!in
works because!
now has an infix mode as long as its followed byin
,is_now
oris_a
.A new class can support
in
by implementing theMembershipTestable
interface, which has a singlecontains
method. The method is required to return aBoolean
.Rename
List.has_element
andRange.has_element
toList.contains
andRange.contains
. AddArray.contains
,Map.contains
(an alias forMap.has_key
), andSet.contains
.Change sets to be non-indexable. The former indexing operation on a set is better expressed using
in
. Mutable sets no longer have an operator form for assignment;MutableSet.add
orMutableSet.remove
must be used, instead.While we're at it, add
Set.add
, renameMutableMap.delete
toMutableMap.remove
, and renameMutableSet.delete
toMutableSet.remove
.