From 83359a4e2bd0b5a233f159f1be9bde2da8f023b2 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 5 Oct 2025 22:55:24 +0800 Subject: [PATCH] Add utility functions to DemoKit - Add greet() function for formatting greetings - Add sum() function for calculating array sums --- Sources/DemoKit/DemoKit.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sources/DemoKit/DemoKit.swift b/Sources/DemoKit/DemoKit.swift index 08b22b8..186edad 100644 --- a/Sources/DemoKit/DemoKit.swift +++ b/Sources/DemoKit/DemoKit.swift @@ -1,2 +1,20 @@ // The Swift Programming Language // https://docs.swift.org/swift-book + +/// A utility structure providing demo functionality +public struct DemoKit { + + /// Formats a greeting message + /// - Parameter name: The name to greet + /// - Returns: A formatted greeting string + public static func greet(_ name: String) -> String { + return "Hello, \(name)! Welcome to DemoKit." + } + + /// Calculates the sum of an array of integers + /// - Parameter numbers: Array of integers to sum + /// - Returns: The sum of all numbers + public static func sum(_ numbers: [Int]) -> Int { + return numbers.reduce(0, +) + } +}