Class: TrueClass

Inherits:
Object show all
Defined in:
lib/source/ruby.rb

Overview

The global value true is the only instance of class TrueClass and represents a logically true value in boolean expressions. The class provides operators allowing true to participate correctly in logical expressions.

Instance Method Summary collapse

Instance Method Details

#&(object) ⇒ Object

call-seq:

true & obj -> !!obj

And – returns false if obj is nil or false, true otherwise.



6685
6686
6687
# File 'lib/source/ruby.rb', line 6685

def &(object)
  `this.valueOf()&&$T(object)`
end

#^(object) ⇒ Object

call-seq:

true ^ obj -> !obj

Exclusive Or – returns true if obj is nil or false, false otherwise.



6709
6710
6711
# File 'lib/source/ruby.rb', line 6709

def ^(object)
  `this.valueOf()?!$T(object):$T(object)`
end

#hashObject

:nodoc:



6713
6714
6715
# File 'lib/source/ruby.rb', line 6713

def hash # :nodoc:
  `'b_'+this.valueOf()`
end

#object_idObject

:nodoc:



6717
6718
6719
# File 'lib/source/ruby.rb', line 6717

def object_id # :nodoc:
  `this.valueOf()?2:0`
end

#to_sObject

call-seq:

true.to_s -> "true"

The string representation of true is “true”.



6726
6727
6728
# File 'lib/source/ruby.rb', line 6726

def to_s
  `$q(''+this)`
end

#|(object) ⇒ Object

call-seq:

true | obj -> true

Or – returns true. Because obj is an argument to a method call, it is always evaluated; there is no short-circuit evaluation.

true |  a = "A assigned"    #=> true
true || b = "B assigned"    #=> true
[a, b].inspect              #=> ["A assigned", nil]


6699
6700
6701
# File 'lib/source/ruby.rb', line 6699

def |(object)
  `this.valueOf()||$T(object)`
end