123456789_123456789_123456789_123456789_123456789_

Class: TrueClass

Relationships & Source Files
Inherits: Object
Defined in: object.c,
object.c

Overview

The class of the singleton object true.

Several of its methods act as operators:

One other method:

Instance Method Summary

Instance Method Details

#&(object) ⇒ Boolean

Returns false if object is false or nil, true otherwise:

true & Object.new # => true true & false # => false true & nil # => false

[ GitHub ]

  
# File 'object.c', line 1506

static VALUE
true_and(VALUE obj, VALUE obj2)
{
    return RBOOL(RTEST(obj2));
}

#===

[ GitHub ]

#^(object) ⇒ !object

Returns true if object is false or nil, false otherwise:

true ^ Object.new # => false
true ^ false      # => true
true ^ nil        # => true
[ GitHub ]

  
# File 'object.c', line 1550

static VALUE
true_xor(VALUE obj, VALUE obj2)
{
    return rb_obj_not(obj2);
}

#to_s ⇒ 'true' #inspect ⇒ 'true'

Alias for #to_s.

#to_s ⇒ 'true' Also known as: #inspect

Returns string 'true':

true.to_s # => "true"

#inspect is an alias for to_s.

[ GitHub ]

  
# File 'object.c', line 1487

VALUE
rb_true_to_s(VALUE obj)
{
    return rb_cTrueClass_to_s;
}

#|(object) ⇒ true

Returns true:

true | Object.new # => true
true | false      # => true
true | nil        # => true

Argument object is evaluated. This is different from true with the short-circuit operator, whose operand is evaluated only if necessary:

true | raise # => Raises RuntimeError.
true || raise # => true
[ GitHub ]

  
# File 'object.c', line 1531

static VALUE
true_or(VALUE obj, VALUE obj2)
{
    return Qtrue;
}