let abbrevName: (String) -> String = { $0.split(separator: " ") .compactMap { $0.first?.uppercased() } .joined(separator: ".") }
func abbrevName(_ name: String) -> String {return name.split(separator: " ").compactMap { $0.first?.uppercased() }.joined(separator: ".")}- let abbrevName: (String) -> String = { $0.split(separator: " ")
- .compactMap { $0.first?.uppercased() }
- .joined(separator: ".") }
let isPerfectSquare: (Int) -> Bool = { pow(pow(CGFloat($0), 0.5), 2) == CGFloat($0) }
func isPerfectSquare(_ input: Int) -> Bool {let inputAsDouble = Double(input)return inputAsDouble.squareRoot().rounded() == inputAsDouble.squareRoot()}- let isPerfectSquare: (Int) -> Bool = { pow(pow(CGFloat($0), 0.5), 2) == CGFloat($0) }
import Glibc // for random() let a = { print(random()) }
- import Glibc // for random()
let a = random()print(a)- let a = { print(random()) }
import XCTest // XCTest Spec Example: // TODO: replace with your own tests (TDD), these are just how-to examples to get you started class SolutionTest: XCTestCase { static var allTests = [ ("Test Example", testExample), ] func testExample() { let actual = 1 XCTAssertEqual(actual, 1) } } XCTMain([ testCase(SolutionTest.allTests) ])
- import XCTest
- // XCTest Spec Example:
- // TODO: replace with your own tests (TDD), these are just how-to examples to get you started
- class SolutionTest: XCTestCase {
- static var allTests = [
- ("Test Example", testExample),
- ]
- func testExample() {
- let actual = 1
- XCTAssertEqual(actual, 1)
- }
- }
- XCTMain([
- testCase(SolutionTest.allTests)
- ])