Quantcast
Channel: The Open Source Experience
Viewing all articles
Browse latest Browse all 10

Bug #1139 – Oops, my bad.

$
0
0

So for those who read my last blog post, you can probably disregard most of it because turns out I made a novice mistake and worked on an old version of processing.js. When I created my branch for my bug in git gui, I forgot to select the branch from 1.1, so it branched from what I assume is the default version 0.7. So I’m going to attempt to do this bug again. In version 1.1, the Arraylist already distinguishes from a number and arraylist parameter.

} else if (arguments.length > 0 && typeof arguments[0] !== ‘number’) {
array = arguments[0];

The code above accepts arguments such as array, objects, array-like objects. I found this site helpful when trying to understand objects, arrays and array-like objects. By changing the code to array.arguments[0].toArray(), the values get copied properly so they can be used. The problem that this creates is that, toArray is a arraylist function, therefore if the constructor receives an array, the toArray function will not be available.
As a result I thought to check for an arraylist and an array.

if(arguments[0].toArray){
array = arguments[0].toArray();
}else if (arguments[0].slice){
array = arguments[0].slice(0);
}

After review, I was told that we should limit the types of acceptable parameters to only Arraylist and number. So I removed the section for array and I had to change the clone() function because it uses an array. I changed it from:

return new ArrayList(array.slice(0));
to
return new ArrayList(this);

Now everything should work, arraylist now accepts an arraylist as a parameter.



Viewing all articles
Browse latest Browse all 10

Trending Articles