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 falseifobjectisfalseornil,trueotherwise:.
- #=== ⇒ Object
- 
  
    
      #^(object)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns trueifobjectisfalseornil,falseotherwise:.
- 
  
    
      #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
| 1512 1513 1514 1515 1516 | # File 'object.c', line 1512 static VALUE true_and(VALUE obj, VALUE obj2) { return RBOOL(RTEST(obj2)); } | 
#=== ⇒ Object
#^(object) ⇒ Object
Returns true if object is false or nil, false otherwise:
true ^ Object.new # => false
true ^ false      # => true
true ^ nil        # => true
| 1556 1557 1558 1559 1560 | # File 'object.c', line 1556 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.
| 1493 1494 1495 1496 1497 | # File 'object.c', line 1493 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
| 1537 1538 1539 1540 1541 | # File 'object.c', line 1537 static VALUE true_or(VALUE obj, VALUE obj2) { return Qtrue; } |