elm-community / elm-community/string-extra

Add firstToUpper and firstToLower to change first character's case

Open
#58 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
36
Forks
27
PR merge metrics
No merged PRs in 30d

Description

I use this sometimes and it would be nice to have in String.Extra I think

``` elm
firstToUpper : String -> String
firstToUpper str =
String.uncons str
|> Maybe.map (Tuple.mapFirst Char.toUpper)
|> Maybe.map (\( c, rest ) -> String.fromChar c ++ rest)
|> Maybe.withDefault str

firstToLower : String -> String
firstToLower str =
String.uncons str
|> Maybe.map (Tuple.mapFirst Char.toLower)
|> Maybe.map (\( c, rest ) -> String.fromChar c ++ rest)
|> Maybe.withDefault str
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.