Andy Wardley wrote:
Josh Rosenbaum wrote:
It seems to me that the hash.delete() vmethod should return the value(s) it deletes.

Hmm, yes, perhaps it should.  Although that does make things slightly less
convenient for the simpler case when you're not interested in the values
returned.

  [% CALL hash.delete('foo') %]  vs [% hash.delete('foo') %]

I wonder if it would be better to have a separate method, say remove(), which
returns the values, leaving delete() to simply delete them and throw the
results away.

That is probably the wise thing to do. Especially given the fact that the code 
may already be in use, and if we turned on outputting of values people might 
start seeing strange things on their site. Another problem would be trying to 
figure out how to return the values since it appears you allow a list of keys 
to be deleted. (Perhaps just as a list.)

hash.remove could maybe do it the standard perl way of just deleting a single 
value. I suppose we could do multiple deletes too. But then that complicates 
things with having to use a list or joining the values. It would be a pain to 
have to do hash.remove('foo').join('') rather than just hash.remove('foo').

-- Josh

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to