ballerina - 一种返回芭蕾舞女演员中代码位置的方法
问题描述
条件检查后如何返回芭蕾舞演员中的代码位置
例如
**Start:**
int value = io:readln("Enter 10: ");
if (value != 10)
{
**goto Start**
}
有没有办法在芭蕾舞演员中实现这一点,以便代码不断返回,直到输入正确的值。
解决方案
您可以尝试使用以下代码示例:
import ballerina/io;
function main(string... args) {
while (true) {
var value = <int>io:readln("Enter 10: ");
match value {
int i => {
if (value != 10) {
continue;
}
break;
}
error e => io:println("Input is not a number.");
}
}
// Following code will be executed if and only if the input is 10
io:println("Success! Input is number 10.");
}
推荐阅读
- c++ - 用于各种参数类型的 C++ 类模板方法
- javascript - 在数组中查找不包含 JavaScript 字符的字符串
- android - Ionic 3 - 读取 NFC 卡?
- database - 从表中获取值(使用条件)并在一个命令中存储在另一个表中
- laravel - 从视图中的当前 URL 获取参数
- ansible - 如何在 Ansible 中使用 virtualenvwrapper 创建 virtualenv
- openshift - 如何降级或卸载 Openshift 客户端
- c++ - minGW (g++) 在 Windows 中与 QT-qmake 自动生成的 Makefile 链接错误
- android - 如何检查应用程序 Project Android Studio 中包含的库的 Android 清单文件?
- bash - 如果它不存在,如何将行添加到节