From 61a49da3efb0a422324551ca419544b53a9de093 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 6 May 2023 23:09:43 +0200 Subject: [PATCH] Improved the implementation of the "isNotEmpty" property in the String+Empty extension. --- Sources/Core/Extensions/String+Empty.swift | 15 ++++++--------- .../Core/Cases/Extensions/String+EmptyTests.swift | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Sources/Core/Extensions/String+Empty.swift b/Sources/Core/Extensions/String+Empty.swift index b3a599a..12636f2 100644 --- a/Sources/Core/Extensions/String+Empty.swift +++ b/Sources/Core/Extensions/String+Empty.swift @@ -12,17 +12,14 @@ public extension String { - // MARK: Properties + // MARK: Constants - /// Represents an empty string. + /// A string that represents an empty string. static let empty = "" - // MARK: Functions - - /// Checks whether a string is not empty. - /// - Returns: A boolean value that represents whether the string is not empty. - func isNotEmpty() -> Bool { - isEmpty == false - } + // MARK: Properties + + /// A Boolean value indicating whether a string is not empty. + var isNotEmpty: Bool { !isEmpty } } diff --git a/Tests/Core/Cases/Extensions/String+EmptyTests.swift b/Tests/Core/Cases/Extensions/String+EmptyTests.swift index 956abf0..23a204f 100644 --- a/Tests/Core/Cases/Extensions/String+EmptyTests.swift +++ b/Tests/Core/Cases/Extensions/String+EmptyTests.swift @@ -31,7 +31,7 @@ final class String_EmptyTests: XCTestCase { let string = String.empty // WHEN - let result = string.isNotEmpty() + let result = string.isNotEmpty // THEN XCTAssertFalse(result) @@ -42,7 +42,7 @@ final class String_EmptyTests: XCTestCase { let string = String.Test.string // WHEN - let result = string.isNotEmpty() + let result = string.isNotEmpty // THEN XCTAssertTrue(result)