diff --git a/spec/std/array_spec.cr b/spec/std/array_spec.cr index 0f44cfb6774e..51ed3e17d74b 100644 --- a/spec/std/array_spec.cr +++ b/spec/std/array_spec.cr @@ -117,6 +117,10 @@ describe "Array" do b = [4, 5, 6] * 10 (a | b).should eq([1, 2, 3, 4, 5, 6]) end + + it "different types" do + ([1, 2, 3] | ["hello"]).should eq([1, 2, 3, "hello"]) + end end it "does +" do diff --git a/src/array.cr b/src/array.cr index 30425c6869e3..1732fc8ddc6f 100644 --- a/src/array.cr +++ b/src/array.cr @@ -307,7 +307,7 @@ class Array(T) end Array(T | U).build(size + other.size) do |buffer| - set = Set(T).new + set = Set(T | U).new appender = buffer.appender each do |obj| appender << obj if set.add?(obj)