Class: NilClass

Inherits:
Object show all
Defined in:
opal/opal/corelib/nil.rb,
opal/opal/corelib/marshal/write_buffer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allocateObject



5
6
7
# File 'opal/opal/corelib/nil.rb', line 5

def allocate
  ::Kernel.raise ::TypeError, "allocator undefined for #{name}"
end

Instance Method Details

#!Object



12
13
14
# File 'opal/opal/corelib/nil.rb', line 12

def !
  true
end

#&(other) ⇒ Object



16
17
18
# File 'opal/opal/corelib/nil.rb', line 16

def &(other)
  false
end

#==(other) ⇒ Object



28
29
30
# File 'opal/opal/corelib/nil.rb', line 28

def ==(other)
  `other === nil`
end

#^(other) ⇒ Object



24
25
26
# File 'opal/opal/corelib/nil.rb', line 24

def ^(other)
  `other !== false && other !== nil`
end

#__marshal__(buffer) ⇒ Object



2
3
4
# File 'opal/opal/corelib/marshal/write_buffer.rb', line 2

def __marshal__(buffer)
  buffer.append('0')
end

#clone(freeze: true) ⇒ Object



36
37
38
# File 'opal/opal/corelib/nil.rb', line 36

def clone(freeze: true)
  nil
end

#dupObject



32
33
34
# File 'opal/opal/corelib/nil.rb', line 32

def dup
  nil
end

#inspectObject



40
41
42
# File 'opal/opal/corelib/nil.rb', line 40

def inspect
  'nil'
end

#instance_variablesObject



81
82
83
# File 'opal/opal/corelib/nil.rb', line 81

def instance_variables
  []
end

#nil?Boolean

Returns:



44
45
46
# File 'opal/opal/corelib/nil.rb', line 44

def nil?
  true
end

#rationalize(*args) ⇒ Object



72
73
74
75
# File 'opal/opal/corelib/nil.rb', line 72

def rationalize(*args)
  ::Kernel.raise ::ArgumentError if args.length > 1
  ::Kernel.Rational(0, 1)
end

#singleton_classObject



48
49
50
# File 'opal/opal/corelib/nil.rb', line 48

def singleton_class
  ::NilClass
end

#to_aObject



52
53
54
# File 'opal/opal/corelib/nil.rb', line 52

def to_a
  []
end

#to_cObject



68
69
70
# File 'opal/opal/corelib/nil.rb', line 68

def to_c
  ::Complex.new(0, 0)
end

#to_hObject



56
57
58
# File 'opal/opal/corelib/nil.rb', line 56

def to_h
  `Opal.hash()`
end

#to_iObject Also known as: to_f



60
61
62
# File 'opal/opal/corelib/nil.rb', line 60

def to_i
  0
end

#to_rObject



77
78
79
# File 'opal/opal/corelib/nil.rb', line 77

def to_r
  ::Kernel.Rational(0, 1)
end

#to_sObject



64
65
66
# File 'opal/opal/corelib/nil.rb', line 64

def to_s
  ''
end

#|(other) ⇒ Object



20
21
22
# File 'opal/opal/corelib/nil.rb', line 20

def |(other)
  `other !== false && other !== nil`
end