// Basic example of initializing and using a Bool value in Mojo
@value
struct Example(Boolable):
    var boolValue: Bool

    // Constructor
    fn __init__(self, value: Bool) -> Void:
        self.boolValue = value

    // Method to demonstrate Bool usage
    fn demonstrateBool(self) -> String:
        if self.boolValue:
            return "True"
        else:
            return "False"

// Usage
let example = Example(true)
print(example.demonstrateBool())  // Output: "True"

Overview

The Bool class in Mojo represents the primitive boolean scalar value, facilitating binary true/false logic in programming. As a built-in, it requires no additional imports and is integral to controlling flow and making decisions in Mojo applications.

Key Features

Use Cases

Considerations

Compatibility

As a built-in type in Mojo, Bool is universally compatible within the Mojo ecosystem. Its operations and behavior are consistent across different platforms that support Mojo, ensuring a seamless development experience regardless of the target environment.