Loading...

June 14, 2010

Groovy Goodness: Capitalize Strings

Groovy 1.7.3 adds the capitalize() method to the String class. This will capitalize the first letter of the String:

assert 'MrHaki' == 'mrHaki'.capitalize()
assert 'Groovy' == 'groovy'.capitalize()
assert 'Groovy is Gr8!' == 'groovy is Gr8!'.capitalize()