- 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.
推薦閱讀
- Cocos2d Cross-Platform Game Development Cookbook(Second Edition)
- 復(fù)雜軟件設(shè)計(jì)之道:領(lǐng)域驅(qū)動(dòng)設(shè)計(jì)全面解析與實(shí)戰(zhàn)
- 深度學(xué)習(xí)經(jīng)典案例解析:基于MATLAB
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- JIRA 7 Administration Cookbook(Second Edition)
- 基于免疫進(jìn)化的算法及應(yīng)用研究
- INSTANT Passbook App Development for iOS How-to
- UML 基礎(chǔ)與 Rose 建模案例(第3版)
- 深入理解Android:Wi-Fi、NFC和GPS卷
- 邊玩邊學(xué)Scratch3.0少兒趣味編程
- Akka入門與實(shí)踐
- Microsoft HoloLens By Example
- Java高手是怎樣煉成的:原理、方法與實(shí)踐
- Java EE 7 Development with WildFly
- Zend Framework 2 Cookbook