Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

ThenElse

Version License Platform

Simplest extension of Bool.

Example

  var odd: Set = [1,3,5,7,9]
  var even: Set = [2,4,6,8,0]

  odd.insert(1).inserted.then {
      print("inserted")
    }.else {
      print("do not inserted")
    }
  // print : "do not inserted"

  let insertResult = even.insert(1).inserted.then{
      return "inserted"
    }.else{
      return "do not inserted"
    }
    
  print("\(insertResult)") // print: "inserted"
    
  let value = 11
    
  let filterArray = (value % 2 == 1)
    .then{ () -> [Int] in
      let arr = [Int](0...value).filter{ $0 % 2 == 1 }
      return arr
    }.else { () -> [Int] in
      let arr = [Int](0...value).filter{ $0 % 2 == 0 }
      return arr
    }
    
  print(filterArray) // print: [1, 3, 5, 7, 9, 11]

Installation

ThenElse is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ThenElse'

Author

devikkim, devikkim@gmail.com

License

ThenElse is available under the MIT license. See the LICENSE file for more info.

You can’t perform that action at this time.