Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is String#pluralize idempotent?

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

string.pluralize == string.pluralize.pluralize
like image 497
hoffm Avatar asked Feb 29 '12 19:02

hoffm


2 Answers

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.

like image 174
Marc Talbot Avatar answered Sep 29 '22 05:09

Marc Talbot


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
like image 20
Ryan Bigg Avatar answered Sep 29 '22 05:09

Ryan Bigg