- 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
.
- 施耐德SoMachine控制器應用及編程指南
- 計算機組裝·維護與故障排除
- 筆記本電腦維修不是事兒(第2版)
- 微服務分布式架構基礎與實戰:基于Spring Boot + Spring Cloud
- 電腦高級維修及故障排除實戰
- SiFive 經典RISC-V FE310微控制器原理與實踐
- Hands-On Artificial Intelligence for Banking
- 單片機技術及應用
- Hands-On Deep Learning for Images with TensorFlow
- 筆記本電腦芯片級維修從入門到精通(圖解版)
- 計算機組成技術教程
- 零基礎輕松學修電腦主板
- Nagios系統監控實踐(原書第2版)
- Exceptional C++:47個C++工程難題、編程問題和解決方案(中文版)
- Hands-On Game Development with WebAssembly