I'm taking a look at the MT5 core classes (Array.mqh, List.mqh, Chart.mqh, etc.), and I see that the reserved word this is never used for referring to the object itself inside the class itself.
This is a very common practice in OO languages as far as I know. In fact, MQL5 allows the use of this, but it seems that it is not necessary, so my questions are the following.
Can we avoid the use of this in MQL5? If so, why MQL5 allows its use?Thank you very much in advance.
This is well explained in the documentation. To resume :
- this keyword isn't mandatory to access members of a class.
- It's a good practice to use it anyway (my opinion).
- If you want to return a reference to an object from a function (method), you have to use it.
This is well explained in the documentation. To resume :
- this keyword isn't mandatory to access members of a class.
- It's a good practice to use it anyway (my opinion).
- If you want to return a reference to an object from a function (method), you have to use it.
Thank you again angevoyageur!
Official Docs only use this for returning the object itself, not for referencing class members. The MQL5 framework does not use this! so I will do the same, I mean Unlike C ++ and Java I am writing the reserved word this only when strictly necessary. I expect everything works!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm taking a look at the MT5 core classes (Array.mqh, List.mqh, Chart.mqh, etc.), and I see that the reserved word this is never used for referring to the object itself inside the class itself.
This is a very common practice in OO languages as far as I know. In fact, MQL5 allows the use of this, but it seems that it is not necessary, so my questions are the following.
Can we avoid the use of this in MQL5? If so, why MQL5 allows its use?Thank you very much in advance.