- Rust Programming Cookbook
- Claus Matzinger
- 130字
- 2021-06-24 12:27:48
There is no null
Functional languages typically don't have a concept of null for the simple reason that it's always a special case. If you strictly follow functional principles, each input must have a workable output—but what is null? Is it an error? Or within normal operating parameters, but a negative result?
As a legacy feature, null has been around since C/C++, when a pointer could actually point to the (invalid) address, 0. However, many new languages try to move away from that. Rust does not have null, and no return value as a normal case with the Option type. The case of error is covered by the Result type, to which we dedicated an entire chapter, Chapter 5, Handling Errors and Other Results.
推薦閱讀
- 微服務設計原理與架構
- Building Mapping Applications with QGIS
- JavaScript入門經典
- 單片機C語言程序設計實訓100例
- Visual Basic程序設計教程
- Python爬蟲、數據分析與可視化:工具詳解與案例實戰
- Kotlin Programming By Example
- 工業機器人離線編程
- Python自然語言理解:自然語言理解系統開發與應用實戰
- Sails.js Essentials
- Android應用開發實戰(第2版)
- Go語言從入門到精通
- 零基礎輕松學C++:青少年趣味編程(全彩版)
- 從零開始學Selenium自動化測試:基于Python:視頻教學版
- PowerDesigner 16 從入門到精通