We mentioned this already in the Copying a series section in Chapter 5, Working with Series and Blocks, but as this is a pitfall for new Red programmers, we will stress it again here—a series (also called a string) local to a function should be initialized with a copy. If not, the series will keep its value over subsequent function calls, which is an unexpected result for newcomers. Here is a correct example of how to initialize a local series using a function:
correct: function[] [ data: copy [] ; correct initialization! append data 108 data]correct ;== [108]correct ;== [108]correct ;== [108]
Run the snippet with data: [] to see for yourself!