- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 94字
- 2021-07-02 23:07:16
Defining the variable value before use
While it is not enforced in some languages, a variable must have an initial value in Rust, even if it is zero. This is good practice, and also helps when it comes to debugging since all variables have known contents. If they didn't, there'd be a risk of undefined behavior.
Undefined behavior means that what the program does is anyone's guess. For instance, if variables did not have initial values, their values would be whatever happens to be in memory at the time that the value is allocated.
推薦閱讀
- GraphQL學習指南
- ThinkPHP 5實戰
- JavaScript+jQuery網頁特效設計任務驅動教程(第2版)
- C語言程序設計基礎與實驗指導
- Network Automation Cookbook
- Blender 3D Incredible Machines
- Nginx Essentials
- Learning Vaadin 7(Second Edition)
- AppInventor實踐教程:Android智能應用開發前傳
- Building RESTful Python Web Services
- Kubernetes進階實戰
- App Inventor 2 Essentials
- Python函數式編程(第2版)
- 深入實踐DDD:以DSL驅動復雜軟件開發
- INSTANT LESS CSS Preprocessor How-to