Class: Ruspea::Runtime::Nill

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ruspea/runtime/nill.rb

Constant Summary collapse

ARRAY =
[].freeze

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



49
50
51
52
# File 'lib/ruspea/runtime/nill.rb', line 49

def ==(other)
  return true if other.is_a? Nill
  false
end

#carObject



13
14
15
# File 'lib/ruspea/runtime/nill.rb', line 13

def car
  nil
end

#cdrObject



21
22
23
# File 'lib/ruspea/runtime/nill.rb', line 21

def cdr
  self
end

#cons(el) ⇒ Object



29
30
31
# File 'lib/ruspea/runtime/nill.rb', line 29

def cons(el)
  return List.new(el, self, count: 1)
end

#countObject



25
26
27
# File 'lib/ruspea/runtime/nill.rb', line 25

def count
  0
end

#empty?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/ruspea/runtime/nill.rb', line 33

def empty?
  true
end

#eq?(other) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/ruspea/runtime/nill.rb', line 41

def eq?(other)
  self == other
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/ruspea/runtime/nill.rb', line 45

def eql?(other)
  self == other
end

#headObject



9
10
11
# File 'lib/ruspea/runtime/nill.rb', line 9

def head
  nil
end

#tailObject



17
18
19
# File 'lib/ruspea/runtime/nill.rb', line 17

def tail
  self
end

#to_a(*_) ⇒ Object



37
38
39
# File 'lib/ruspea/runtime/nill.rb', line 37

def to_a(*_)
  ARRAY
end