diff options
| -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: |
