forked from swift-server/swift-aws-lambda-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBusiness.swift
33 lines (32 loc) · 1.33 KB
/
Business.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftAWSLambdaRuntime open source project
//
// Copyright (c) 2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
extension String {
/// Returns a new string with the first character capitalized and the remaining characters in lowercase.
///
/// This method capitalizes the first character of the string and converts the remaining characters to lowercase.
/// It is useful for formatting strings where only the first character should be uppercase.
///
/// - Returns: A new string with the first character capitalized and the remaining characters in lowercase.
///
/// - Example:
/// ```
/// let example = "hello world"
/// print(example.uppercasedFirst()) // Prints "Hello world"
/// ```
func uppercasedFirst() -> String {
let firstCharacter = prefix(1).capitalized
let remainingCharacters = dropFirst().lowercased()
return firstCharacter + remainingCharacters
}
}