3 ms·
That's not the correct plural rule in English, you'd want let plural = match cases.len() { 0 | 2.. => "s", 1 => "", }; or something (t
by cyphar 5y ago
That's not the correct plural rule in English, you'd want
let plural = match cases.len() {
0 | 2.. => "s",
1 => "",
};
or something (though to be fair the original code snippet also handled "0" incorrectly -- should be "cases.len() != 1").
- iudqnolq 5y agoAnd also to be fair you probably don't want to be hardcoding English pluralization rules.
- rabidferret 5y agoI used to maintain a library which actually tried to implement proper English pluralization rules. I can confirm you don't want to do that.