Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camel casing hyphenated English words (e.g. re-render)

Tags:

camelcasing

Typically if you're converting a string of words to camel case you capitalise only the first letter of every word (bar the first word).

How does this apply to hyphenated words like re-render?

Something deep inside me wants it to be rerender or doRerender. And not reRender or doReRender, which just looks wrong to me.

Is this open to interpretation or is camel casing clear on this, and I'm just not seeing it?

like image 611
Simon Hartcher Avatar asked May 25 '17 01:05

Simon Hartcher


People also ask

What do you call two words hyphenated?

Compound words can be written in three ways: as open compounds (spelled as two words, e.g., ice cream), closed compounds (joined to form a single word, e.g., doorknob), or hyphenated compounds (two words joined by a hyphen, e.g., long-term). Sometimes, more than two words can form a compound (e.g., mother-in-law).

How do you make a CamelCase?

CamelCase is a way to separate the words in a phrase by making the first letter of each word capitalized and not using spaces. It is commonly used in web URLs, programming and computer naming conventions. It is named after camels because the capital letters resemble the humps on a camel's back.


1 Answers

In camel-case, individual trailing words are capitalized and whitespace is dropped. Since "re-render" is a single word, and since the hyphen is a non-alpha character in the same vein as whitespace, it should be treated as a single word would normally.

let rerender = "The correct answer";

The same would be true for these other examples containing hyphenated prefixes (as opposed to hyphenated standalone words):

sub-zero wedding cake         : subzeroWeddingCake
co-parent advisory hose       : coparentAdvisoryHose
ongoing trans-oceanic puppies : ongoingTransoceanicPuppies
like image 87
isherwood Avatar answered Sep 27 '22 21:09

isherwood