假设我有2个可以互相呼叫的功能
public static function goToAction($action,$sender_id)
{
$actions = array();
$logic = file_get_contents('../../logic/logic.json');
$logic_array = json_decode($logic, true);
unset($logic);
if (!isset($logic_array[$action])) {
return false;
} else {
foreach ($logic_array[$action] as $action) {
$actions[] = self::parseActionType($action,$sender_id);
}
}
return $actions;
}
public static function parseActionType($actions,$sender_id)
{
$data = array();
foreach ($actions as $key => $action) {
switch ($key) {
case 'goto': {
$goto_actions = self::goToAction($action,$sender_id);
foreach ($goto_actions as $goto_action){
$data[] = $goto_action;
} break;
...
}
}
return $data;
}
这是我的json文件:
"no_return": [
{ "text": "Должно быть: 1, 2, 3"},
{ "text": "1" },
{ "goto": "2nr", "no_return": true},
{ "text": "5" }
],
"2nr": [
{ "text": "2" },
{ "goto": "3", "no_return": true},
{ "text": "4"}
],
"3nr": [
{ "text": "3" }
],
它返回12345,它是正确的,但是如果将no_return
设置为true
,如何才能返回123?也许函数必须返回一些东西?
答案 0 :(得分:0)
proto_library(
name = "GreeterServices_proto",
srcs = ["GreeterServices.proto"],
deps = [
"@googleapi//:annotations_proto",
])
使用循环内部的break会停止它,即使剩下更多的元素,还有继续这将结束当前运行并继续下一个元素。