struct Bool

Overview

Bool has only two possible values: true and false. They are constructed using these literals:

true  # A Bool that is true
false # A Bool that is false

See Bool literals in the language reference.

Defined in:

bool.cr
json/to_json.cr
primitives.cr
yaml/to_yaml.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)Source

def self.new(pull : JSON::PullParser)Source

Instance Method Detail

def !=(other : Bool) : BoolSource

Returns true if self is not equal to other.

def &(other : Bool) : BoolSource

Bitwise AND. Returns true if this bool and other are true, otherwise returns false.

false & false # => false
false & true  # => false
true & false  # => false
true & true   # => true

def ==(other : Bool) : BoolSource

Returns true if self is equal to other.

def ^(other : Bool) : BoolSource

Exclusive OR. Returns true if this bool is different from other, otherwise returns false.

false ^ false # => false
false ^ true  # => true
true ^ false  # => true
true ^ true   # => false

def clone : BoolSource

def hash(hasher)Source

def to_json(json : JSON::Builder) : NilSource

def to_s(io : IO) : NilSource

Appends "true" for true and "false" for false to the given IO.

def to_s : StringSource

Returns "true" for true and "false" for false.

def to_unsafe : LibC::IntSource

Returns an integer derived from the boolean value, for interoperability with C-style booleans.

The value is 1 for true and 0 for false.

def to_yaml(yaml : YAML::Nodes::Builder) : NilSource

def |(other : Bool) : BoolSource

Bitwise OR. Returns true if this bool or other is true, otherwise returns false.

false | false # => false
false | true  # => true
true | false  # => true
true | true   # => true

© 2012–2021 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/1.2.1/Bool.html