零,最无害的返回值,也是最坏的谎言
原创
你有没有遇到过这样的场景:一个函数返回0,你以为是失败了,其实0就是正确答案?我越来越觉得,用零作为返回值是最隐蔽的设计陷阱。它太普通了,普通到没人会质疑——但正是这种无意识,让bug悄无声息地潜伏在代码深处。成功还是失败,空值还是正常值,全靠调用方猜。这不是优雅,这是把理解成本转嫁给下游的人。下次再想用0表示"无"的时候,停下来想想:真的没有更好的办法?
原文:Zero Is the Worst Return Value · 来源:Hacker News
版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除
相关文章
- 【IT 早报】2026年10月25日 - 本周要闻与趋势
- Tailscale 漏洞报告遭质疑:真实威胁还是 AI 垃圾?
- Over $1.4B has been traded on prediction markets for the 2026 midterms
- AI大模型的投票倾向研究:Grok选共和党92%,GPT选民主党97%,二者一致性不到10%
- An animated explainer of the PHP2SHell vulnerability [video]
- Sound of a guitar string cooling down on a piezo contact mic [video]
- How to fix your life in 1 day
- Ming dynasty statue unearthed in WA returns to China
- Google has officially turned these Nest thermostats back into dumb thermostats
- Show HN: Omni Verify, my AI agent can't post until Kane checks every promise
最新文章
- 【IT 早报】2026年10月25日 - 本周要闻与趋势 12分钟前
- Tailscale 漏洞报告遭质疑:真实威胁还是 AI 垃圾? 43分钟前
- Over $1.4B has been traded on prediction markets for the 2026 midterms 46分钟前
- AI大模型的投票倾向研究:Grok选共和党92%,GPT选民主党97%,二者一致性不到10% 47分钟前
- An animated explainer of the PHP2SHell vulnerability [video] 2小时前
- Sound of a guitar string cooling down on a piezo contact mic [video] 2小时前
- How to fix your life in 1 day 2小时前
- Ming dynasty statue unearthed in WA returns to China 3小时前
- Google has officially turned these Nest thermostats back into dumb thermostats 3小时前
- Show HN: Omni Verify, my AI agent can't post until Kane checks every promise 3小时前
itfan123



![An animated explainer of the PHP2SHell vulnerability [video]](https://www.itfans123.com/zb_users/theme/yd1125free/include/random/9.jpg)
![Sound of a guitar string cooling down on a piezo contact mic [video]](https://www.itfans123.com/zb_users/theme/yd1125free/include/random/4.jpg)
