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

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

Adds an array, NumArray or numeric value to the existing NumArray
С версии: 1.0.0
public add ( mixed $addend )
$addend mixed an other int, float, array or NumArray
    public function add($addend)
    {
        if ($addend instanceof NumArray) {
            $addend = $addend->getData();
        }
        $this->data = Map::mapArray($this->data, $addend, 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::add
  */
 public function testAddCache()
 {
     $numArray = new NumArray(5);
     $numArray->setCache('key', 6);
     $numArray->add(4);
     $this->assertFalse($numArray->inCache('key'));
 }
All Usage Examples Of NumPHP\Core\NumArray::add