Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7472

Missing uncapitalize method

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.3
    • Fix Version/s: 2.4.8
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      Groovy has had a `capitalize` method since 1.8.2 but it does not have the mirror opposite: `uncapitalize`. A few weeks ago I was working with string manipulations and was surprised by this omission.

      Based on http://docs.groovy-lang.org/latest/html/groovy-jdk/java/lang/CharSequence.html#capitalize() the rules for uncapitalize should be as follows:

      assert 'H'.uncapitalize() == 'h'
      assert 'Hello'.uncapitalize() == 'hello'
      assert 'Hello world'.uncapitalize() == 'hello world'
      assert 'Hello World'.uncapitalize() == 'hello World'
      assert 'hello world' ==
          'Hello World'.split(' ').collect{ it.uncapitalize() }.join(' ')
      

        Attachments

          Activity

            People

            • Assignee:
              aalmiray Andres Almiray
              Reporter:
              aalmiray Andres Almiray
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: