Logical simplification -
Miguel_Leopold - 15.07.2015
Hello, i need help, my mind is made knots.
How do you do this shorter?
PHP код:
if(ViewType != SponsorView || realObject == true)
{
if(ViewType != PhysicalView || realObject == true)
{
ExecuteThis();
}
}
if someone gives me a tutorial of advanced logic operations, it would greatly appreciate it.
Re: Logical simplification -
iMFear - 15.07.2015
https://sampforum.blast.hk/showthread.php?tid=216730 (i think, this is useful to you.)
Re: Logical simplification -
Jimmy0wns - 15.07.2015
Try this:
PHP код:
if(ViewType != SponsorView && ViewType != PhysicalView || realObject == true)
{
ExecuteThis();
}
Respuesta: Logical simplification -
Miguel_Leopold - 15.07.2015
Quote:
Originally Posted by iMFear
|
thanks, I had already read this post (very useful), but I think I look anything like exercises / examples.
Quote:
Originally Posted by Jimmy0wns
Try this:
PHP код:
if(ViewType != SponsorView && ViewType != PhysicalView || realObject == true)
{
ExecuteThis();
}
|
Not works :S
Re: Logical simplification -
Beckett - 15.07.2015
pawn Код:
if(ViewType != SponsorView || realObject == true)
{
if(ViewType != PhysicalView || realObject == true)
{
ExecuteThis();
}
}
First of all; Why are you performing the statement '
realObject == true' twice? While you checked if it was true above that statement.
By the way it changes nothing, I prefer doing this
pawn Код:
if(ViewType != SponsorView || realObject == true)
{
if(ViewType != PhysicalView)
{
ExecuteThis();
}
}
Than this.
Anyway you could go ahead and try this code:
pawn Код:
if(ViewType != SponsorView || realObject == true && ViewType != PhysicalView)
{
ExecuteThis();
}
Respuesta: Re: Logical simplification -
Miguel_Leopold - 15.07.2015
Quote:
Originally Posted by DaniceMcHarley
pawn Код:
if(ViewType != SponsorView || realObject == true) { if(ViewType != PhysicalView || realObject == true) { ExecuteThis(); } }
First of all; Why are you performing the statement ' realObject == true' twice? While you checked if it was true above that statement.
By the way it changes nothing, I prefer doing this
pawn Код:
if(ViewType != SponsorView || realObject == true) { if(ViewType != PhysicalView) { ExecuteThis(); } }
Than this.
Anyway you could go ahead and try this code:
pawn Код:
if(ViewType != SponsorView || realObject == true && ViewType != PhysicalView) { ExecuteThis(); }
|
An example with
ViewType = EditorView //(!=PhysicalView,!=SponsorView)
and
realObject = true
and replacing
with my code:
PHP код:
if(false|| true)
{
if(false|| true)
{
ExecuteThis(); //executed
}
}
With your code:
PHP код:
if(false|| true)
{
if(false)
{
ExecuteThis();//not executed
}
}
Are not the same.
Come on, you're a High-roller
AW: Logical simplification -
Kaliber - 15.07.2015
Your code...can't work..try this:
PHP код:
if((ViewType != SponsorView && ViewType != PhysicalView) || realObject == true)
{
ExecuteThis();
}
Respuesta: AW: Logical simplification -
Miguel_Leopold - 15.07.2015
Quote:
Originally Posted by Kaliber
Your code...can't work..try this:
PHP код:
if((ViewType != SponsorView && ViewType != PhysicalView) || realObject == true)
{
ExecuteThis();
}
|
After a thousand trials and error, you got it. 
The parentheses are important.