I found weird behavior within replace list item

I'm not sure if this is an expected behavior, but I just thought this is quite weird, so I'm posting this here

:

Those blocks in left and right is almost identical, except for that the left one has <set "x" to get "name"> block.

A set of blocks here is meant to subtract the second item within 3-items-list, while I'm trying to make a custom procedure that returns interval time between two time list.

So the variable "x" and "name" is identical, until item 2 of "name" gets replaced with item 2 + 1 "name".

and a blockset returns subtraction between item 2 of each list,
while the left one returns 0 while the other does 1.

set "x" to get "name" does make the difference here, as shown in screenshot

and I thought this is unexpected, because that action goes before replacing item 2


and one more, the pattern S in Clock.FormatDateTime shows a tenth of second, while this page says it stands for millisecond.

You have stumbled upon the inner secret of lists.
You set variable x to point to the data inside variable name, so operations on one are seen also in the other variable.

If you want to avoid this overlap effect, use the list copy block.
More list fun:

Oh yeah I just forgot.. thx for pointing that out but how about the millisecond and the pattern S thing?

Is that also expected behavior where I overlooked some point?

Try

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.