| Autor | Zpráva | ||
|---|---|---|---|
| Fasut1 Profil * |
#1 · Zasláno: 16. 3. 2012, 05:56:48
namespace System\Collections;
class Collection extends \ArrayObject
{
private $itemType = null;
function setItemType($value) { $this->itemType = $value; }
function getItemType() { return $this->itemType; }
function offsetSet($index, $newval)
{
if (is_null($this->itemType)) parent::offsetSet($index, $newval);
else
{
if ($newval instanceof $this->itemType) parent::offsetSet($index, $newval);
else throw new InvalidTypeException;
}
}
}
class InvalidTypeException extends \Exception
{
}Ahoj potreboval by som vytvorit kolekciu do ktorej sa budu dat vlozit len parametre urciteho typu (nieco ako genercke kolekcie) mam to spravne? |
||
|
Časová prodleva: 14 let
|
|||
0