2
votes

A generic case for strings
Lars Fosdal
– Do you rememeber the discussion about a case statement for strings? I got this flash idea after reading Jolyon Smith's "The case for case[]", a and remembering a comment from Francisco Ruiz on Nick Hodges' article on a THTMLWriter which suggested using a default array property in a creative fashion.Honestly, it is not really a true case statement, and it might not be as fast as an if then else, but here is how it looks when used. A bit ugly. but good fun :)program TestGenericsSwitch;{$apptype Console}uses GenericsSwitch;begin TStringSwitch.CaseOf('chARLie') ['Any', ...
Statistics
|
Visits by Source |
User Actions |