Skip to content

Latest commit

 

History

History
35 lines (20 loc) · 1.19 KB

Boolean.md

File metadata and controls

35 lines (20 loc) · 1.19 KB

Solidity Tutorial: all about booleans

Table of Content

How to define a boolean variable in Solidity?

Variable of boolean type are defined by the keyword bool . They can contain a constant value of either true or false;

Operators related to booleans

  • ! (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.

Comparisons operators and booleans

The following comparison operators <= (less than or equal), < (less than), ==!=, >=, > evaluate to a boolean value.

References