Logical simplification
#1

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.
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=216730 (i think, this is useful to you.)
Reply
#3

Try this:

PHP код:
if(ViewType != SponsorView && ViewType != PhysicalView || realObject == true

    
ExecuteThis(); 

Reply
#4

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
Reply
#5

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();
}
Reply
#6

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
Reply
#7

Your code...can't work..try this:

PHP код:
if((ViewType != SponsorView && ViewType != PhysicalView) || realObject == true

    
ExecuteThis(); 

Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)