Article 2TYQM CodeSOD: Plurals Dones Rights

CodeSOD: Plurals Dones Rights

by
Ellis Morning
from The Daily WTF on (#2TYQM)

Fra_Luca_Pacioli_Letter_S_1509.png

Today, submitter Adam shows us how thoughtless language assumptions made by programmers are also hilarious language assumptions:

"So we're querying a database for data matching *title* but then need to try again with plural/singular if we didn't get anything. Removing the trailing S is bad, but what really caught my eye was how we make a word plural. Never mind any English rules or if the word is actually Greek, Chinese, or Klingon."
if ((locs == NULL || locs->Length() == 0) && (title->EndsWith(@"s") || title->EndsWith(@"S"))){ title->RemoveCharAt(title->Length()-1); locs = data->GetLocationsForWord(title);}else if ((locs == NULL || locs->Length() == 0) && title->Length() > 0){ WCHAR c = title->CharAt(title->Length()-1); if (c >= 'A' && c Append(@"S"); } else { title->Append(@"s"); } locs = data->GetLocationsForWord(title);}

Untils nexts times: II...IIII^1IfIIs &s aes, Hochs!

puppetlabs50.png[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today! TheDailyWtf?d=yIl2AUoC8zAtg-kUr6NP4c
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments