Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 890
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you, but that's not quite what you need. You have several closing conditions for one magician, but you need the opposite.
This is how I came up with it:
Will it work? Or what is wrong?It's... How can I put this delicately...
What'sthe switch for, if the code is for one magician?
But you could use ifs if you like, but we'd have to think about conditions.
For example
if ((OrderMagicNumber()==10011&&10033)&&(...)
wouldn't it be blamed at compile time?
This is... How can I put it gently...
What's the switch for then, if the code is for one magician?
Maybe I don't understand the switch, but in its expression there is one magician, which is compared to several variants of closing conditions.
ZS: saw the sequel. I haven't compiled it yet as I haven't finished the code. Numbers can't be enumerated using an AND operation?
Then how do I get out of it? Repeat for each magician?
ZZZY: Actually, it's not AND, but OR.
Then how do you get out of it? Repeat it for every wizard?
Yeah.
And about a switch still you should read a primer, there on the contrary, any number of variants is processed (case 0:..., case 1:..., case N:..., where number = value of a magician). I was too lazy to write in the example, so I only had enough time to write two magicians and the default variant ;)
Yeah
I guess you don't have to write out the OR for each magician after all?
I guess you don't have to write out an OR for each magician, do you?
Yeah.
And still read a primer about a switch, there on the contrary, any number of variants is processed (case 0:..., case 1:..., case N:..., where number = value of a magician). I was too lazy to write in the example, so I only had enough time to write two magicians and the default option ;)
And yet in the switch you get the same repetition of the same closing condition for different mages as you do with ifs.
The only question is which variant will eat more bits.
And yet in the switch you get the same repetition of the same closing condition for different mages as you do with ifs.
The only question is which variant will eat more bits.
And yet in the switch you get the same repetition of the same closing condition for different mages as you do with ifs.
The only question is which variant will eat more bits.
This is the same branching as if(), it just looks neater and is easier to code if there are three or more single choices of integers to choose from. If there are only two options, or if non-numeric expressions are being compared, then only if(). And by if() you can combine several options (if( option1 && option2 || option3 ) {action;}), while in switch you cannot directly, only one at a time.
{
case 1: Act according to variant 1; break;
case 2: action on option 2; break;
case 3: action on option 3; break;
default: default action; break;
}
else if( option2 ) { actions by option 2; }
else if( option3 ) { actions by option 3; }
else { default action; }