query
On this page

toSentenceCase

lib.toSentenceCase

Docs pulled from | This Revision | 26 minutes ago


Nixpkgs manual

Converts the first character of a string s to upper-case.

Inputs

str
The string to convert to sentence case.

Type

toSentenceCase :: String -> String

Examples

lib.strings.toSentenceCase usage example

toSentenceCase "home"
=> "Home"
(lib.strings.toSentenceCase)

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

toSentenceCase =
    str:
    if !isString str then
      throw "toSentenceCase does only accepts string values, but got ${typeOf str}"
    else
      let
        firstChar = substring 0 1 str;
        rest = substring 1 (-1) str; # -1 takes till the end of the string
      in
      toUpper firstChar + toLower rest;