Discussing the article: "From Basic to Intermediate: Array (II)"

 

Check out the new article: From Basic to Intermediate: Array (II).

In this article, we will look at what a dynamic array and a static array are. Is there a difference between using one or the other? Or are they always the same? When should you use one and when the other type? And what about constant arrays? We will try to understand what they are designed for and consider the risks of not initializing all the values in the array.

There are essentially two ways to declare an array. One is by declaring a static array, and the other is by declaring it as a dynamic array. While in practice, understanding each type is relatively straightforward, there are certain subtle nuances that can complicate or even prevent a clear understanding of what a dynamic array and a static array really are. Especially when considering other programming languages, such as C and C++. However, even here in MQL5, there may be moments where you find yourself somewhat unsure. This is because the fundamental and essential difference between a static and a dynamic array lies in the ability of the latter to change size during the execution of the code.

Thinking about it this way, it seems simple enough to classify an array as either dynamic or static. However, it's important to remember that a string is also an array. Though it's a special kind of array. This makes it complicated to classify it as strictly static or dynamic. Nonetheless, let's set this fact aside. We will not delve into the string type directly. Thus we will avoid confusion and to ensure we develop a clear understanding of this topic.


Author: CODE X