17

为什么牛逼的程序员都不用 “ ! = null-程序员麦冬

 3 years ago
source link: https://blog.51cto.com/14849432/2541637
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
问题为了避免空指针调用,我们经常会看到这样的语句...if (someobject != null) {    someobject.doCalc();}...最终,项目中会存在大量判空代码,多么丑陋繁冗!如何避免这种情况?我们是否滥用了判空呢?精华回答这是初、中级程序猿经常会遇到的问题。他们总喜欢在方法中返回null,因此,在调用这些方法时,也不得不去判空。另外,也许受此习惯影响,他们总潜意识地

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK