Capitalize in Swift

Published on 24 April 2026 (Updated: 24 April 2026)

Welcome to the Capitalize in Swift page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

import Foundation

let args = CommandLine.arguments.dropFirst()

let sentence = args
    .joined(separator: " ")
    .trimmingCharacters(in: .whitespacesAndNewlines)

guard !sentence.isEmpty else {
    print("Usage: please provide a string")
    exit(1)
}

let result = sentence.prefix(1).uppercased() + sentence.dropFirst()

print(result)

Capitalize in Swift was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.