Giter Club home page Giter Club logo

Comments (8)

paulbruneau avatar paulbruneau commented on June 27, 2024

I use the former

from objective-c-style-guide.

chrisladd avatar chrisladd commented on June 27, 2024

Speaking of clarity "former" and "latter" are the parts-of-speech equivalents of ternary operators. ;)

from objective-c-style-guide.

mattbischoff avatar mattbischoff commented on June 27, 2024

I think

if (text.length) {
    [array addObject:text];
}

is the more common style on the team. Anyone have a problem if we write this one in?

Edit: Edited code example

from objective-c-style-guide.

murdocdv avatar murdocdv commented on June 27, 2024

I think - length is a method, so unless I misunderstood the dot-syntax rules, should be:

If ([text length] > 0) {
[array addObject:text];
}

I prefer the > 0 formulation because its more clear you're testing an integer value, and not a nil check.

On Aug 4, 2013, at 11:55 AM, Matthew Bischoff [email protected] wrote:

I think

if(text.length){
[array addObject:text];
}
is the more common style on the team. Anyone have a problem if we write this one in?


Reply to this email directly or view it on GitHub.

from objective-c-style-guide.

mattbischoff avatar mattbischoff commented on June 27, 2024

You're right. Updated my post to make it a method, but I'm still proposing no > 0.

from objective-c-style-guide.

segiddins avatar segiddins commented on June 27, 2024

I disagree about it not being a nil check. It also will return 0 if text is nil, so it's an easy way to check both the existence of text and make sure its contents aren't empty.

-Samuel E. Giddins

On Aug 4, 2013, at 12:02 PM, Matthew Bischoff [email protected] wrote:

You're right. Updated my post to make it a method, but I'm still proposing no > 0.


Reply to this email directly or view it on GitHub.

from objective-c-style-guide.

JThramer avatar JThramer commented on June 27, 2024
if ([text length]) {
    [thing doSomething];
}

is perfectly valid code, and will excecute [thing doSomething] on any value 1 or greater.

from objective-c-style-guide.

mattbischoff avatar mattbischoff commented on June 27, 2024

I’d recommend closing this issue.

from objective-c-style-guide.

Related Issues (20)

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.