Skip to content

Instantly share code, notes, and snippets.

@raj-pranav
Created January 25, 2022 20:15
Show Gist options
  • Save raj-pranav/ef6eb6ab9628b6f6731257e72531d6b8 to your computer and use it in GitHub Desktop.
Save raj-pranav/ef6eb6ab9628b6f6731257e72531d6b8 to your computer and use it in GitHub Desktop.
Operators in Solidity
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
uint constant T = 10;
contract Logical_Operation {
uint x = 10;
uint y = 20;
bool a = x > y ; // a is false
bool b = x < y; // b is true
// Logical AND
bool test1 = a && b; // false && true -> false
bool test2 = a && false; // false && false -> false
bool test3 = true && b; // true && true -> true
bool test4 = true && false; // true && false -> false
// Logical OR
bool test5 = a || b; // false && true -> true
bool test6 = a || false; // false && false -> false
bool test7 = true || b; // true && true -> true
bool test8 = true ||false; // true && false -> true
// Logical NOT
bool test9 = !a; // test9 will be true
bool test10 = !b; // test10 will be false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment