Class: NilClass

Inherits:
Object
  • Object
show all
Defined in:
opal/opal/corelib/nil_class.rb

Instance Method Summary collapse

Instance Method Details

#&(other) ⇒ Object



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

def &(other)
  false
end

#==(other) ⇒ Object



14
15
16
# File 'opal/opal/corelib/nil_class.rb', line 14

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

#^(other) ⇒ Object



10
11
12
# File 'opal/opal/corelib/nil_class.rb', line 10

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

#dupObject

Raises:



18
19
20
# File 'opal/opal/corelib/nil_class.rb', line 18

def dup
  raise TypeError
end

#inspectObject



22
23
24
# File 'opal/opal/corelib/nil_class.rb', line 22

def inspect
  'nil'
end

#nil?Boolean

Returns:



26
27
28
# File 'opal/opal/corelib/nil_class.rb', line 26

def nil?
  true
end

#object_idObject Also known as: hash



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

def object_id
  `#{NilClass}._id || (#{NilClass}._id = $opal.uid())`
end

#singleton_classObject



30
31
32
# File 'opal/opal/corelib/nil_class.rb', line 30

def singleton_class
  NilClass
end

#to_aObject



34
35
36
# File 'opal/opal/corelib/nil_class.rb', line 34

def to_a
  []
end

#to_hObject



38
39
40
# File 'opal/opal/corelib/nil_class.rb', line 38

def to_h
  `$opal.hash()`
end

#to_iObject Also known as: to_f



42
43
44
# File 'opal/opal/corelib/nil_class.rb', line 42

def to_i
  0
end

#to_sObject



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

def to_s
  ''
end

#|(other) ⇒ Object



6
7
8
# File 'opal/opal/corelib/nil_class.rb', line 6

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