NumPHP\Core\NumArray::sub PHP Метод

sub() публичный Метод

Subtracts an array, NumArray or numeric value from the existing NumArray
С версии: 1.0.0
public sub ( mixed $subtrahend )
$subtrahend mixed an other int, float, array or NumArray
    public function sub($subtrahend)
    {
        if ($subtrahend instanceof NumArray) {
            $subtrahend = $subtrahend->getData();
        }
        $this->data = Map::mapArray($this->data, $subtrahend, function ($data1, $data2) {
            return $data1 - $data2;
        });
        $this->shape = Shape::getShape($this->data);
        $this->flushCache();
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Tests if cache will be flushed after use of NumArray::sub
  */
 public function testSubCache()
 {
     $numArray = new NumArray(5);
     $numArray->setCache('key', 7);
     $numArray->sub(3);
     $this->assertFalse($numArray->inCache('key'));
 }
All Usage Examples Of NumPHP\Core\NumArray::sub