Runtime assertions for Ruby literal.fun
ruby
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support mapping unions

+9
+4
lib/literal/types/union_type.rb
··· 91 91 self[key] or raise KeyError.new("Key not found: #{key.inspect}") 92 92 end 93 93 94 + def map(type, &) 95 + Literal::Types::UnionType.new([*@primitives.map(&), *@types.map(&)]) 96 + end 97 + 94 98 def >=(other) 95 99 types = @types 96 100 primitives = @primitives
+5
test/types/_kind.test.rb
··· 29 29 30 30 assert _Kind(_Array(Integer)) === _Array(1) 31 31 assert _Kind(_Array(numeric_kind.type)) === _Array(1) 32 + 33 + union_type = _Union(String, Integer) 34 + union_kind = union_type.map(Literal::Types::KindType) { |it| _Kind(it) } 35 + 36 + assert union_kind === Integer 32 37 end