- 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.
推薦閱讀
- 嵌入式軟件系統測試:基于形式化方法的自動化測試解決方案
- Spring技術內幕:深入解析Spring架構與設計
- x86匯編語言:從實模式到保護模式(第2版)
- 網店設計看這本就夠了
- Spring實戰(第5版)
- PhoneGap Mobile Application Development Cookbook
- Java EE 7 Performance Tuning and Optimization
- The DevOps 2.5 Toolkit
- Flutter跨平臺開發入門與實戰
- Cybersecurity Attacks:Red Team Strategies
- Apache Camel Developer's Cookbook
- 3ds Max印象 電視欄目包裝動畫與特效制作
- RESTful Web Clients:基于超媒體的可復用客戶端
- Kotlin進階實戰
- Selenium Essentials