W3cubDocs

/Crystal 0.31

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

Defined in:

bool.cr
primitives.cr
json/to_json.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)Source

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)Source

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–2019 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.31.1/Bool.html