bool: The possible values are constants - true and false.
Boolean Operators:
! (Logical negation)
&& (logical conjunction, “and”)
|| (logical disjunction, “or”)
== (equality)
!= (inequality)
The operators || and && apply the common short-circuiting rules. This means that in the expression f(x) || g(y), if f(x) evaluates to true, g(y) will not be evaluated even if it may have side effects.
Examples:
bool isPaid = true;
Boolean values can be modified within contracts and can be used in both incoming and outgoing parameters and the return value, as shown in the following example:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
contract BooleanExample {
bool public myBool;
function setMyBool(bool myBool) public {
myBool = myBool;
}
}
For more content, follow me on - https://linktr.ee/shlokkumar2303
Top comments (0)