Download MetaTrader 5

Learning the code syntax

To add comments, please log in or register
florenceale
137
florenceale  

Hello what does it mean this expression?...I'm confused with ? : etc.


double price = (type == OP_SELL) ? Ask : Bid;
Carl Schreiber
Moderator
7813
Carl Schreiber  

Easiest and fastest way:

  1. mark the ?
  2. press F1
  3. start reading!
florenceale
137
florenceale  

cant find anything in that way...

whroeder1
16764
whroeder1  
  1. florenceale: what does it mean this expression?...I'm confused with ? : etc.

    Ternary Operator ?: - Operators - Language Basics - MQL4 Reference

  2. florenceale: cant find anything in that way...
    Why not? Press F1 (help)


florenceale
137
florenceale  

yes thanks i had found it but by google. It means either or.

Fernando Carreiro
3868
Fernando Carreiro  
florenceale: Hello what does it mean this expression?...I'm confused with ? : etc.
// Concise version
double price = (type == OP_SELL) ? Ask : Bid;

// Verbose version
double price;
if (type == OP_SELL)
   price = Ask;
else
   price = Bid;

// Yet another version
double price = Bid;
if (type == OP_SELL) price = Ask;
To add comments, please log in or register