Initialing a boolean variable thru comparison operator
There are time when we try to compare and the point is only to initialize a boolean variable. Sample,
if(var1 == var2)
{
bVar = true;
}
else
{
bVal = false;
}
So, instead of the long code above you can shorten it to:
bVar = (var1 == var2);
That's it!
if(var1 == var2)
{
bVar = true;
}
else
{
bVal = false;
}
So, instead of the long code above you can shorten it to:
bVar = (var1 == var2);
That's it!
Comments
Post a Comment