- 追加された行はこの色です。
- 削除された行はこの色です。
class Foo {
private $val = 0;
private $pool = array();
public function getVal($key) {
if (!isset($this->pool[$key])) {
$this->pool[$key] = $this->create();
}
return $this->pool[$key];
}
private function create() {
return ++$this->val;
}
public function clear($key) {
unset($this->pool[$key]);
}
}
$f = new Foo;
print $f->getVal(1) . "\n"; # 1
print $f->getVal(1) . "\n"; # 1
print $f->getVal(2) . "\n"; # 2
print $f->getVal(1) . "\n"; # 1
$f->clear(1);
print $f->getVal(1) . "\n"; # 3