Small Basic Arrays: Empty Elements

Empty Array Elements

The ability to have array elements hold empty strings can become handy in many programming tasks. Let’s say that we have an array named score that has fives elements as shown below:

score[1] = 80

score[2] = 85

score[3] = 90

score[4] = 95 

score[5] = 92

If you want to wipe out the 90 score, you write:

score[3] = ""

The two arrays, before and after this statement are shown in the Figure below. As expected, the statement score[3]="" only clears the contents of the third element of the score array; all other elements remain in their positions unchanged.

 

Figure: Illustrating what happens when we delete an element from an array

 

Let's end with some critical thinking questions...

Why is this valuable? Why would you want to remove an element from an array? What could you do with the array that you couldn't otherwise do?

  

 

Do you have any questions? Ask us! We're full of answers and other fine things!

Head to the Small Basic forum to get the most answers to your questions: 

https://social.msdn.microsoft.com/Forums/en-US/smallbasic/threads/   

And go to https://blogs.msdn.com/SmallBasic to download Small Basic and learn all about it!

  

Small and Basically yours

- Ninja Ed & Majed Marji