How do I make a list?

Hey, @hekknyt

You should definitely read Brian's thread to understand how lists in Snap! work :slight_smile:

For a quick start however, this might help:

Snap!'s list block is a reporter (ovally shaped block that reports a value and can be used as an input to other blocks (e.g. the item _ of _).




If you want to use the add block to add stuff to a list programmatically, you have to create a variable.
As the add block requires a list as its second input, you have to take care that your variable is set to a list first.

This script doesn't work, because the variable my list is not of the list type.






If you initialize the list first, by setting the variable my list to an empty list, it works:



Of course you can not only use the command block add to extend your list, but also the function in front of, e.g. like this:

However, as Brian mentioned, you shouldn't combine those 2 ways of dealing with lists, because the internal representation of these lists is different (linked list vs. array) whether you use the in front of block or the add block and you might want to avoid converting between two data types all the time.

Hope that helps,
cheers,
jadga