summaryrefslogtreecommitdiff
path: root/lists.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-12-04 09:50:27 +0100
committerjmoenig <jens@moenig.org>2013-12-04 09:50:27 +0100
commit24ad14399c0ef5d7fa27e18dd0c6279099da1d78 (patch)
tree10b13ef6b617e49c5d4e9065c987e1edb9f5eac2 /lists.js
parent9faa4844d4ab528e5f689afdd042efe07ab81605 (diff)
downloadsnap-byow-24ad14399c0ef5d7fa27e18dd0c6279099da1d78.tar.gz
snap-byow-24ad14399c0ef5d7fa27e18dd0c6279099da1d78.zip
harmonize equality testing and List CONTAINS testing
Diffstat (limited to 'lists.js')
-rw-r--r--lists.js22
1 files changed, 5 insertions, 17 deletions
diff --git a/lists.js b/lists.js
index 2bbcd0b..60cd7e3 100644
--- a/lists.js
+++ b/lists.js
@@ -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: