Class: Literal::Types::UnionType

Inherits:
Object
  • Object
show all
Defined in:
lib/literal/types/union_type.rb

Instance Method Summary collapse

Constructor Details

#initialize(*types) ⇒ UnionType

Returns a new instance of UnionType.



2
3
4
# File 'lib/literal/types/union_type.rb', line 2

def initialize(*types)
  @types = types
end

Instance Method Details

#===(value) ⇒ Object



10
11
12
# File 'lib/literal/types/union_type.rb', line 10

def ===(value)
  @types.any? { |type| type === value }
end

#inspectObject



6
7
8
# File 'lib/literal/types/union_type.rb', line 6

def inspect
  "Union(#{@types.map(&:inspect).join(", ")})"
end