in reply to Re^4: 'state' variables and unit testing (intentional)
in thread 'state' variables and unit testing
Unlike the solution using state the my in an enclosing block allows you to include controlled access to the cache.
{ my $_cache; sub withLongComputation { $_cache //= ...; ... } sub clearCache { undef $_cache; } }
Jenda
Enoch was right!
Enjoy the last years of Rome.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: 'state' variables and unit testing (intentional)
by tobyink (Canon) on Feb 04, 2014 at 13:08 UTC |