Class: NilClass

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

Instance Method Summary collapse

Instance Method Details

#!Object



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

def !
  true
end

#&(other) ⇒ Object



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

def &(other)
  false
end

#==(other) ⇒ Object



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

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

#^(other) ⇒ Object



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

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

#dupObject

Raises:



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

def dup
  raise TypeError
end

#inspectObject



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

def inspect
  'nil'
end

#nil?Boolean

Returns:



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

def nil?
  true
end

#object_idObject Also known as: hash



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

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

#singleton_classObject



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

def singleton_class
  NilClass
end

#to_aObject



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

def to_a
  []
end

#to_hObject



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

def to_h
  `$opal.hash()`
end

#to_iObject Also known as: to_f



46
47
48
# File 'opal/opal/corelib/nil_class.rb', line 46

def to_i
  0
end

#to_sObject



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

def to_s
  ''
end

#|(other) ⇒ Object



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

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