7

That is, for any String string, does the following hold?

string.pluralize == string.pluralize.pluralize
hoffm
  • 2,386
  • 23
  • 36

2 Answers2

6

pluralize is NOT idempotent. I can prove it by example (courtesy of a personal Facebook posting that hit some language geeks).

"taxi".pluralize
=> "taxis"
"taxis".pluralize
=> "taxes"
"taxi".pluralize.pluralize
=> "taxes"

So "taxi" (the thing that drives you around) to "taxis" (an arrangement or order) to "taxes" (the proper pluralization of "taxis"). I'm sure there are other examples, but they are certainly hard to come by.

Not looking for score or acceptance on this answer, but I couldn't really fit this nicely into the comments on Ryan's post.

Marc Talbot
  • 2,059
  • 2
  • 21
  • 27
  • 1
    As of Rails 5 (and maybe earlier?), this counterexample no longer works. `"taxi".pluralize` => `"taxis"` and `"taxi".pluralize.pluralize` => `"taxis"` – hoffm Oct 19 '17 at 14:55
  • What happens if I want to pluralize taxis? Probably still the right call though. – Marc Talbot Oct 20 '17 at 01:07
4

I cannot think of a case where it wouldn't.

I just tried the following words and it doesn't change after a second pluralizaation. However, some of them do "break" in interesting ways because of two reasons: 1) Rails' pluralization rules are actually quite dumb and 2) English is hard.

  • analysis -> analyses -> analysis
  • media -> media -> media
  • news -> news -> news
  • cactii -> cactiis -> cactiis
  • criterion -> criterions -> criterions
  • foot -> foots -> foots
  • loaf -> loafs -> loafs
  • person -> people -> people
Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261