diff options
| author | jmoenig <jens@moenig.org> | 2013-12-04 09:50:27 +0100 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-12-04 09:50:27 +0100 |
| commit | 24ad14399c0ef5d7fa27e18dd0c6279099da1d78 (patch) | |
| tree | 10b13ef6b617e49c5d4e9065c987e1edb9f5eac2 | |
| parent | 9faa4844d4ab528e5f689afdd042efe07ab81605 (diff) | |
| download | snap-yow-24ad14399c0ef5d7fa27e18dd0c6279099da1d78.tar.gz snap-yow-24ad14399c0ef5d7fa27e18dd0c6279099da1d78.zip | |
harmonize equality testing and List CONTAINS testing
| -rwxr-xr-x | history.txt | 2 | ||||
| -rw-r--r-- | lists.js | 22 |
2 files changed, 6 insertions, 18 deletions
diff --git a/history.txt b/history.txt index b5f1e6d..a9a711c 100755 --- a/history.txt +++ b/history.txt @@ -2023,4 +2023,4 @@ ______ 131204 ------ * Threads: handle text comparisons case-insensitive (again) - +* Lists: harmonize equality testing and List CONTAINS testing @@ -61,7 +61,7 @@ PushButtonMorph, SyntaxElementMorph, Color, Point, WatcherMorph, StringMorph, SpriteMorph, ScrollFrameMorph, CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize, MorphicPreferences*/ -modules.lists = '2013-October-08'; +modules.lists = '2013-December-04'; var List; var ListWatcherMorph; @@ -209,30 +209,18 @@ List.prototype.at = function (index) { }; List.prototype.contains = function (element) { - var num = parseFloat(element); if (this.isLinked) { - if (this.first === element) { + if (snapEquals(this.first, element)) { return true; } - if (!isNaN(num)) { - if (parseFloat(this.first) === num) { - return true; - } - } if (this.rest instanceof List) { return this.rest.contains(element); } - return false; } // in case I'm arrayed - if (contains(this.contents, element)) { - return true; - } - if (!isNaN(num)) { - return (contains(this.contents, num)) - || contains(this.contents, num.toString()); - } - return false; + return this.contents.some(function (any) { + return snapEquals(any, element); + }); }; // List conversion: |
