Skip to content

jeden/swiftplusplus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SwiftPlusPlus

SwiftPlusPlus simply brings the pre and post increment and decrement operators back to Swift 3, so that you can write this again:

var index: Int

index++
++index

--index
index--

Note that it works as a standalone statement, without returning the variable value before or after the increment/decrement. So do NOT expect to use it in code like:

if index++ { 
    ...
}

That's just a personal choice - I think that usage may introduce subtle bugs, so I have never used, nor I use in C++ or other languages where these operators are available.

However, I love the operator when used standalone. Maybe for historical reasons, as it's the first thing I learned and loved in C, long long ago.

Installation

Manual

Just copy the SwiftPlusPlus.swift file into your Xcode project

Cocoapods

pod 'SwiftPlusPlus'

Carthage

N/A yet

Swift Package Manager

N/A yet

Usage

Manual installation

In case of manual installation, the operators can be used anywhere in the code without any import.

Cocoapods

Using cocoapods instead you need to add import spp in each file where the operators are used.

Carthage

N/A yet

Swift Package Manager

N/A yet

License

MIT Read the LICENSE file

About

The ++ and -- operators, back to Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published