Class: TrueClass
Overview
The class of the singleton object true
.
Several of its methods act as operators:
-
#&
-
#|
-
#===
-
#^
One other method:
-
#to_s and its alias #inspect.
Instance Method Summary collapse
-
#&(object) ⇒ Boolean
Returns
false
ifobject
isfalse
ornil
,true
otherwise:. - #=== ⇒ Object
-
#^(object) ⇒ Object
Returns
true
ifobject
isfalse
ornil
,false
otherwise:. -
#to_s ⇒ Object
(also: #inspect)
Returns string
'true'
:. -
#|(object) ⇒ true
Returns
true
:.
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
1473 1474 1475 1476 1477 |
# File 'object.c', line 1473
static VALUE
true_and(VALUE obj, VALUE obj2)
{
return RBOOL(RTEST(obj2));
}
|
#=== ⇒ Object
#^(object) ⇒ Object
1517 1518 1519 1520 1521 |
# File 'object.c', line 1517
static VALUE
true_xor(VALUE obj, VALUE obj2)
{
return rb_obj_not(obj2);
}
|
#to_s ⇒ Object Also known as: inspect
Returns string 'true'
:
true.to_s # => "true"
TrueClass#inspect is an alias for TrueClass#to_s.
1454 1455 1456 1457 1458 |
# File 'object.c', line 1454
VALUE
rb_true_to_s(VALUE obj)
{
return rb_cTrueClass_to_s;
}
|
#|(object) ⇒ true
1498 1499 1500 1501 1502 |
# File 'object.c', line 1498
static VALUE
true_or(VALUE obj, VALUE obj2)
{
return Qtrue;
}
|