Variable length parameters.

 

Is there a workaround? Using arrays is not a good idea, since arrays can only store variables of the same type.

Print

It enters a message in the Expert Advisor log. Parameters can be of any type.

void  Print(
   argument,     // first value
   ...           // next values
   );
Documentation on MQL5: Common Functions / Print
Documentation on MQL5: Common Functions / Print
  • www.mql5.com
Data of double type are shown with the accuracy of up to  16 digits after a decimal point, and can be output either in traditional or in scientific format, depending on what entry will be more compact. Data of float type are output with 5 digits after a decimal point. To output real numbers with another accuracy or in a predefined format, use...
 
Nelson Wanyama :

Is there a workaround? Using arrays is not a good idea, since arrays can only store variables of the same type.

Print

It enters a message in the Expert Advisor log. Parameters can be of any type.

Where did you see the array in the 'Print' function?

 
Nelson Wanyama:
Is there a workaround? Using arrays is not a good idea, since arrays can only store variables of the same type.

it's called variadic arguments/template or splat operator or pack argument..

Wiliiam wrote a workaround here

https://www.mql5.com/en/forum/238421

Define Variadic Arguments in Functions?
Define Variadic Arguments in Functions?
  • 2018.04.19
  • www.mql5.com
Can We define functions that like Print("Hello","World"," !"); http://www.equestionanswers.com/c/variadic-function...
 
Vladimir Karputov:

Where did you see the array in the 'Print' function?

That is a custom implementation, trying to duplicate the Print function. And I have asked for a better alternative
 
Sardion Maranatha:

it's called variadic arguments/template or splat operator or pack argument..

Wiliiam wrote a workaround here

https://www.mql5.com/en/forum/238421

It could work, but against my principles of clean code. I'm implementing python types in MQL5. Seems the idea I have is cleaner and more efficient. I'll post when it's complete.
Reason: