Skip to content

Commit

Permalink
Merge pull request #20 from ankurp/discardable
Browse files Browse the repository at this point in the history
Adding @discardableResult for each functions in Array
  • Loading branch information
ankurp authored Nov 6, 2016
2 parents 05015d9 + ef91ea7 commit e9f9712
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cent.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Cent"
s.version = "6.0.2"
s.version = "6.0.3"
s.summary = "Extension for common object types for Swift Language"
s.homepage = "https://github.com/ankurp/Cent"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand All @@ -12,5 +12,5 @@ Pod::Spec.new do |s|
s.osx.deployment_target = "10.10"
s.tvos.deployment_target = "9.0"
s.watchos.deployment_target = "2.0"
s.dependency "Dollar", "~> 6.0.0"
s.dependency "Dollar", "~> 6.1.0"
end
2 changes: 2 additions & 0 deletions Cent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
92180C6E1C711845003BA0E3 /* Dollar.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Dollar.xcodeproj; path = Dollar/Dollar.xcodeproj; sourceTree = "<group>"; };
924F92DC195F8338003DBB60 /* Cent.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cent.framework; sourceTree = BUILT_PRODUCTS_DIR; };
92E6688119F0B89600BB4FB8 /* CentTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CentTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
92EF83611DCF815700D7F4FD /* Try.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Try.playground; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -113,6 +114,7 @@
924F92D2195F8338003DBB60 = {
isa = PBXGroup;
children = (
92EF83611DCF815700D7F4FD /* Try.playground */,
92180C6E1C711845003BA0E3 /* Dollar.xcodeproj */,
924F92DE195F8338003DBB60 /* Cent */,
924F92EB195F8338003DBB60 /* CentTests */,
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import PackageDescription
let package = Package(
name: "Cent",
dependencies: [
.Package(url: "https://github.com/ankurp/Dollar", majorVersion: 6, minor: 0)
.Package(url: "https://github.com/ankurp/Dollar", majorVersion: 6, minor: 1)
])
8 changes: 4 additions & 4 deletions Sources/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public extension Array {
///
/// - parameter callback: The callback function to invoke that take an element
/// - returns: array itself
func eachWithIndex(callback: (Int, Element) -> ()) -> [Element] {
@discardableResult func eachWithIndex(callback: (Int, Element) -> ()) -> [Element] {
for (index, elem) in self.enumerated() {
callback(index, elem)
}
Expand All @@ -50,8 +50,8 @@ public extension Array {
///
/// - parameter callback: The callback function to invoke
/// - returns: The array itself
func each(callback: (Element) -> ()) -> [Element] {
_ = self.eachWithIndex { (index, elem) -> () in
@discardableResult func each(callback: (Element) -> ()) -> [Element] {
self.eachWithIndex { (index, elem) -> () in
callback(elem)
}
return self
Expand All @@ -62,7 +62,7 @@ public extension Array {
/// - parameter when: The condition to check each element against
/// - parameter callback: The callback function to invoke
/// - returns: The array itself
func each(when: (Element) -> Bool, callback: (Element) -> ()) -> [Element] {
@discardableResult func each(when: (Element) -> Bool, callback: (Element) -> ()) -> [Element] {
return $.each(self, when: when, callback: callback)
}

Expand Down
3 changes: 3 additions & 0 deletions Try.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Cent

[1, 2, 3].each { print($0) }
4 changes: 4 additions & 0 deletions Try.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>

0 comments on commit e9f9712

Please sign in to comment.