- 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
.
- Learning SQL Server Reporting Services 2012
- ATmega16單片機項目驅動教程
- 龍芯應用開發標準教程
- 數字道路技術架構與建設指南
- Deep Learning with PyTorch
- 計算機組裝·維護與故障排除
- Linux運維之道(第2版)
- 基于ARM的嵌入式系統和物聯網開發
- 3ds Max Speed Modeling for 3D Artists
- 計算機維修與維護技術速成
- Large Scale Machine Learning with Python
- R Deep Learning Essentials
- Practical Machine Learning with R
- Creating Flat Design Websites
- 基于Proteus仿真的51單片機應用