- Unreal Development Kit Game Programming with UnrealScript:Beginner's Guide
- Rachel Cordone
- 216字
- 2021-08-27 11:59:09
Flow control
We learned about comparisons and logical operators earlier. Now what do we do if we want different things to happen depending on the results of those comparisons? Flow control helps us do exactly that. Let's learn how we can specify what happens under different circumstances.
If else
If/else is the basic flow control statement. Let's look at this sentence:
If it's raining I'll take an umbrella.
Using an if statement, that sentence would be written like this:
if(bRaining) { bUmbrella = true; }
We could also add an else statement to it:
If it's raining I'll take an umbrella, otherwise I'll wear short sleeves.
That would be written like this:
if(bRaining) { bUmbrella = true; } else { bShortSleeves = true; }
We can also use Else If for other conditions.
If it's raining I'll take an umbrella, or if it's cold I'll wear a coat, otherwise I'll wear short sleeves.
We could write that like this:
if(bRaining) { bUmbrella = true; } else if(Temperature < ComfortableTemperature) { bCoat = true; } else { bShortSleeves = true; }
The important thing to remember about else/if is, that only one of these conditions will run. If it's raining and cold, only the bRaining
section of the code will run, not bRaining
and Temperature < ComfortableTemperature
.
- 深入淺出SSD:固態存儲核心技術、原理與實戰
- 嵌入式技術基礎與實踐(第5版)
- 電腦組裝、維護、維修全能一本通(全彩版)
- BeagleBone Robotic Projects
- RISC-V處理器與片上系統設計:基于FPGA與云平臺的實驗教程
- WebGL Hotshot
- Java Deep Learning Cookbook
- 新編電腦組裝與硬件維修從入門到精通
- 觸摸屏應用技術從入門到精通
- 嵌入式系統原理及應用:基于ARM Cortex-M4體系結構
- 微服務實戰(Dubbox +Spring Boot+Docker)
- Building Machine Learning Systems with Python
- USB應用分析精粹:從設備硬件、固件到主機端程序設計
- 創客電子:Arduino和Raspberry Pi智能制作項目精選
- 從企業級開發到云原生微服務:Spring Boot實戰