Phpml\Math\Set::union PHP Method

union() public static method

Creates the union of A and B.
public static union ( Set $a, Set $b ) : Set
$a Set
$b Set
return Set
    public static function union(Set $a, Set $b) : Set
    {
        return new self(array_merge($a->toArray(), $b->toArray()));
    }

Usage Example

Example #1
0
 public function testUnion()
 {
     $union = Set::union(new Set([3, 1]), new Set([3, 2, 2]));
     $this->assertInstanceOf('\\Phpml\\Math\\Set', $union);
     $this->assertEquals(new Set([1, 2, 3]), $union);
     $this->assertEquals(3, $union->cardinality());
 }