Hey @vini_brito: Glad you found that interesting!
As for Bubble lists: YES, a Bubble list of any type is just its JavaScript equivalent. So, just as in JS, I can say:
a = [1,1,1,1,1]
And we can push that array to a plugin’s output. (Or, in Run JavaScript, I could just return [1,1,1,1,1] ). What you will see is that the returned “list” is an array(5) full of “1”.
It is only when we do a list operation on it that our array of ones transforms into an array(1) of a single “1”.
The reason this is not obvious (beyond not being documented) is that, in vanilla Bubble we cannot ever create [1,1,1,1,1]. We will always wind up with [1] because there are no constructors beyond “add list” and “plus item”… which de-dupe the array.
As for List Shifter and duplicate array elements: List Shifter’s PROCESS List function takes any of List Shifter’s internal arrays (which can be the “Original List”, “Shifted List”, “Processed List” or “Do Once” (which is just a single-element array that contains [0])) and loop over them, doing something for each iteration.
So, let us say that List Shifter’s “Original List” is an array of 5 Products (Product being a Bubble object). We can, in the PROCESS List action (if Process Action Type is set to number) do as follows:
STEP 1:
- We can leave operand X empty
- We can leave the Operator dropdown empty
- We can enter the numeral 1 in Operand Y
(What this does is to say, “Simply return the number 1 in this step.”)
We can then set “Push to Processed List” to “yes”.
What this will do is – for each iteration – push the number 1 on to the Processed List. So we get (for each step):
Processed List.push(1)
So, at the end of iteration (over 5 items) we have the array:
[1, 1, 1, 1, 1]
And this gets published to List Shifter’s “Processed List” output.
We can also do things like randomly access the elements of Processed List and set them to new values. This is how the “in the page” version keeps track of the Quantities in that scenario.