Class: TrueClass
Overview
Instance Method Summary
-
#&(object) ⇒ Boolean
Returns
falseifobjectisfalseornil,trueotherwise: -
#==(other) ⇒ Boolean
Alias for Module#==.
- #===
-
#^(object) ⇒ !object
Returns
trueifobjectisfalseornil,falseotherwise: -
#inspect ⇒ 'true'
Alias for #to_s.
-
#to_s ⇒ 'true'
(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
# File 'object.c', line 1556
static VALUE
true_and(VALUE obj, VALUE obj2)
{
return RBOOL(RTEST(obj2));
}
#==(other) ⇒ Boolean
Alias for Module#==. Returns whether self and other are the same object:
object = Object.new
object == object # => true
object == Object.new # => false
Here in class Object, #==, #equal?, and #eql? are the same method.
A subclass may override #== to provide class-specific meaning.
Unlike #==, the #equal? method should never be overridden by
subclasses as it is used to determine object identity (that is,
a.equal?(b) if and only if a is the same
object as b):
obj = "a"
other = obj.dup
obj == other #=> true
obj.equal? other #=> false
obj.equal? obj #=> true
The #eql? method returns true if obj and other
refer to the same hash key. This is used by ::Hash to test members
for equality. For any pair of objects where #eql? returns true,
the #hash value of both objects must be equal. So any subclass
that overrides #eql? should also override #hash appropriately.
For objects of class ::Object, #eql? is synonymous
with #==. Subclasses normally continue this tradition by aliasing
#eql? to their overridden #== method, but there are exceptions.
::Numeric types, for example, perform type conversion across #==,
but not across #eql?, so:
1 == 1.0 #=> true
1.eql? 1.0 #=> false
#===
[ GitHub ]
#^(object) ⇒ !object
# File 'object.c', line 1600
static VALUE
true_xor(VALUE obj, VALUE obj2)
{
return rb_obj_not(obj2);
}
#to_s ⇒ 'true'
#inspect ⇒ 'true'
true'
#inspect ⇒ 'true'
Alias for #to_s.
#to_s ⇒ 'true' Also known as: #inspect
# File 'object.c', line 1537
VALUE
rb_true_to_s(VALUE obj)
{
return rb_cTrueClass_to_s;
}
#|(object) ⇒ true
# File 'object.c', line 1581
static VALUE
true_or(VALUE obj, VALUE obj2)
{
return Qtrue;
}