Comments (8)
I use the former
from objective-c-style-guide.
Speaking of clarity "former" and "latter" are the parts-of-speech equivalents of ternary operators. ;)
from objective-c-style-guide.
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.
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.
You're right. Updated my post to make it a method, but I'm still proposing no > 0
.
from objective-c-style-guide.
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.
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.
I’d recommend closing this issue.
from objective-c-style-guide.
Related Issues (20)
- "command + z "does not work
- Execute HOT 2
- Fix broken links HOT 2
- hello
- Any plans on a swift style guide? HOT 2
- Request Create README_id-ID.md HOT 1
- let me try it
- Apple objetive C documet link don't work HOT 2
- Long time no see HOT 1
- Account has been flagged HOT 1
- printing prime numbers in N range without using function in python HOT 2
- Constants can be changed? HOT 1
- test
- test issue HOT 1
- test issue HOT 1
- obj-©
- how to convert string to Boolean?
- Ik
- Switch case
- Archive this repository HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objective-c-style-guide.