HomeDevCentral

Provide boolean object to compute

Description

Provide boolean object to compute

Summary:
The Boolean objet allows to represent a boolean and perform logical operations.

Allow to apply the main logical operations:

  • and()
  • or()
  • not()

Allow to apply logical secondary operations:

  • xor()
  • implication()
  • equivalence()

Allow to convert to other scalar types:

  • asBool()
  • asInteger() when you need 0 or 1
  • asString() for debug representation

*Use case*

The main motivation is $result &= $callback() uses the bitwise operator &
and as such will return 0 or 1 instead of true and false.

With Boolean, $result.and($callback()) will work as expected.

Test Plan:
Unit tests provided

Equivalence tables have been checked against the English Wikipedia
article Boolean algebra.

Reviewers: dereckson

Reviewed By: dereckson

Differential Revision: https://devcentral.nasqueron.org/D3222

Details

Provenance
derecksonAuthored on Jul 2 2023, 17:57
derecksonPushed on Jul 2 2023, 18:50
Reviewer
dereckson
Differential Revision
D3222: Provide boolean object to compute
Parents
rKOTe3954ce91546: Implement any() and all() for all collections
Branches
Unknown
Tags
Unknown