YaLinqo\Functions::increment PHP Method

increment() public static method

Increment function: returns incremental integers starting from 0.
public static increment ( ) : callable
return callable
    public static function increment()
    {
        $i = 0;
        return function () use(&$i) {
            return $i++;
        };
    }

Usage Example

示例#1
0
 function testIncrement()
 {
     /** @var $f callback */
     $f = F::increment();
     $this->assertSame(0, $f());
     $this->assertSame(1, $f());
     $this->assertSame(2, $f());
     $g = F::increment();
     $this->assertSame(0, $g());
     $this->assertSame(1, $g());
     $this->assertSame(3, $f());
 }
All Usage Examples Of YaLinqo\Functions::increment