sumit kang
sumit kang

Reputation: 476

How to write the compare line with better syntax

This is my line of code.

Can I replace this with much more graceful syntax?

if ( colDiffuseCompare == colDiffuseReplace && colAmbientCompare  ==   colAmbientReplace && colEmissionCompare == colEmissionReplace &&     colSpecularCompare == colSpecularReplace)
        {
            return true;
        }
        else
        {

           return false;
        }

Upvotes: 2

Views: 46

Answers (1)

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

You don't need the if() for such case:

 return colDiffuseCompare == colDiffuseReplace && 
        colAmbientCompare == colAmbientReplace && 
        colEmissionCompare == colEmissionReplace &&     
        colSpecularCompare == colSpecularReplace;

There's no way to avoid combining the single conditions though.

Upvotes: 3

Related Questions