4.4 Cómo controlar el flujo de programa utilizando declaraciones if... else.
How to control the program flow by using if... else statements
En el caso de una estructura de control del tipo if... else, un bloque de código siempre será ejecutado.
In the case of an if... else statement, one block of code will always be executed.
if... elif... else - sentencias que te permiten ejecutar código solo cuando se cumplen ciertas condiciones
if... elif... else - statements that allow you to execute code only when certain conditions are met.
Como puede ver, la mayor parte de la función es una estructura if... else que compara el nombre de intención de la solicitud con un conjunto de intentos que acepta el juego.
As you can see, most of the function is an if... else structure that compares the intent name from the request to a set of intents the game accepts.
Luego, agregamos este bloque if... else - podríamos llamar a esto el código de inicialización, como se ha establecido para cuando carga la app por primera vez
Next, add this if... else block - we could call this the initialization code, as it structures the app when it first loads
Con el uso de una sencilla declaración if... else, la primera respuesta se envía si la solicitud se recibe durante el horario comercial y se envía la otra si se recibe fuera de ese periodo.
Using a simple if... else statement, the first response is sent if the request is received during business hours and the other is sent if it is not.
La sintaxis de un if... else if... else declaración en lenguaje de programación Go es
Una de las estructuras condicionales es la estructura If... Else... End if, la cual direcciona el flujo del programa a través de una o dos rutas.
One branching structure is the If... Else... End if structure, which directs program flow along one of two paths.
Sin embargo, después de unos 'if... else', encuentro rápidamente el siguiente 'switch'
But after some nested 'if... else', I find the following 'switch'
Para comparar, esta es la versión con If... Else... End if del mismo método
For comparison, here is the If... Else... End if version of the same method
Un ejemplo mas complejo de usar comprensiones de lista sería agregando expresiones condicionales... if... else... dentro de ellas.
A more complex example of using list comprehensions would be adding... if... else... conditional expressions inside them.
El bloque que maneja las excepciones se codifica de manera análoga a un bloque if... then... else
Try/Except The exception handling block is coded rather like an if... then... else block
Conținut posibil inadecvat
Exemplele au rolul de a te ajuta să traduci cuvinte sau expresii corect si adaptat la context. Nu sunt selectate sau validate manual, așadar pot conține termeni inadecvați. Te rugăm să raportezi exemplele pe care le consideri inadecvate. Traducerile vulgare sau colocviale sunt în general marcate cu roșu sau cu portocaliu.
Înregistrează-te pentru a accesa mai multe exemple