Code Monkey home page Code Monkey logo

swiftyobjc's Introduction

SwiftyObjC

let a = @"hello"; //a is `NSString *const` now
a = @"world"; //produces error

var b = 5; //b is `const int` now
b = 10; //fine

iflet(c, [self getNullableString]) {
    // c is not nil here
}
// c is not available here

ifletwhere(c, [self getNullableString], c.length > 5) {
    // can have additional constraints
}

Requirements

Xcode 8

Installation

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

pod 'SwiftyObjC'

guard/guard let

They are possible but not implemented because it has two significant flaws:

  • I can't ensure else block has return/throw at compile time. Without this I find it too dangerous
  • I can't ensure one wrote else keyword, so again dangerous.

However, I'm looking forward to implement these, so if you found a way how to trick compiler, feel file a note or PR.

License

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

swiftyobjc's People

Contributors

redetection avatar

Stargazers

Valentine Silvansky avatar Míng avatar  avatar

Watchers

James Cloos avatar

Forkers

iwill

swiftyobjc's Issues

iflet() is dangerous

It's a nice feature but consider this code:

for (int i = ...) {
    iflet (x, getValue(i)) {
        if (x->y > 10) continue;
        // Do something 
    }
    // Do something else
}

The programmer and reader expects the continue statement to continue the outer for-loop. But what it really does it continuing one of the hidden inner for-loops of iflet. This can lead to very annoying and hard to find bugs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.