Swift iOS 24-Hour Trainer. Mishra Abhishek
Чтение книги онлайн.
Читать онлайн книгу Swift iOS 24-Hour Trainer - Mishra Abhishek страница 11
A control flow statement allows you to modify the order of statements executed, execute certain statements multiple times, or execute certain statements conditionally.
if-else
The if statement is one such control statement. In its basic form an if statement executes a block of statements only if a specific condition is met.
The test condition is usually a Boolean variable, or an expression that evaluates to a Boolean variable. If the test condition evaluates to true, the following statement (or block of statements) is executed. The following is a simple example:
In this hypothetical game example, a player is required to collect a certain number of red and blue marbles. A player wins the game if he collects more red marbles than blue ones. The test condition in this case is the expression
which evaluates to true in this particular case. Note the complete if statement contains both the test condition and the block of statements that go with the test condition.
Конец ознакомительного фрагмента.
Текст предоставлен ООО «ЛитРес».
Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.
Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.