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.



6728
6729
6730
# File 'lib/source/ruby.rb', line 6728

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.



6752
6753
6754
# File 'lib/source/ruby.rb', line 6752

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

#hashObject

:nodoc:



6756
6757
6758
# File 'lib/source/ruby.rb', line 6756

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

#object_idObject

:nodoc:



6760
6761
6762
# File 'lib/source/ruby.rb', line 6760

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

#to_sObject

call-seq:

true.to_s -> "true"

The string representation of true is “true”.



6769
6770
6771
# File 'lib/source/ruby.rb', line 6769

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]


6742
6743
6744
# File 'lib/source/ruby.rb', line 6742

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