We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2eda647 commit ab892b9Copy full SHA for ab892b9
008
008-logical-operators.sol
@@ -0,0 +1,38 @@
1
+// SPDX-License-Identifier: GPL-3.0
2
+
3
+pragma solidity >=0.7.0 <0.9.0;
4
5
+/**
6
+ * Logical operators
7
+ */
8
9
+contract LogicalOperators {
10
+ uint256 public a = 5;
11
+ uint256 public b = 10;
12
13
+ // logical not
14
+ function logicalNot() public view returns (bool) {
15
+ if (!(a > b)) {
16
+ return true;
17
+ }
18
+ return false;
19
20
21
+ // AND: &&
22
+ function logicAND() public view returns (bool) {
23
+ // both conditions must be fulfilled
24
+ if ((a > b) && (a == b)) {
25
26
27
28
29
30
+ // OR: &&
31
+ function logicOR() public view returns (bool) {
32
+ // atleast one condition should be fulfilled
33
+ if ((a > b) || (a == b)) {
34
35
36
37
38
+}
0 commit comments