Skip to content

Commit 3991042

Browse files
committed
Merge pull request processing-js#27 from Pomax/t1889
Fixed ArrayList constructor to accept 'anything that has .toArray' instead of just ArrayList
2 parents fc5d757 + eb88381 commit 3991042

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

processing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@
471471
function ArrayList(a) {
472472
var array;
473473

474-
if (a instanceof ArrayList) {
474+
if (a && a.toArray) {
475475
array = a.toArray();
476476
} else {
477477
array = [];

test/unit/arrayListFromSet.pde

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
HashMap<String,String> map = new HashMap<String,String>();
2+
map.put("a","1");
3+
4+
ArrayList<String> keys = new ArrayList(map.keySet());
5+
_checkEqual(keys.get(0), "a");
6+
7+
ArrayList<String> vals = new ArrayList(map.values());
8+
_checkEqual(vals.get(0), "1");

0 commit comments

Comments
 (0)