【发布时间】:2020-02-02 14:49:34
【问题描述】:
我正在使用 groovy 开发 DSL,由于我是这种语言的新手,所以我正在努力解决一些问题。
我有这个代码
def from(state1) {
def closure
closure = { sensor ->
[becomes: { signal ->
// someProcess;
[and: closure]
}]
}
[to: { state2 ->
// someProcess
[when: closure]
}]
};
我所做的就是读这种句子
from "on" to "off" when "button" becomes "high" and "button2" becomes "high"
and "button2" becomes "high",是可选的。所以从语法上讲,一切都按照我的意愿进行。
问题是我想增加治疗or 的可能性,像这样:
from "on" to "off" when "button" becomes "high" or "button2" becomes "high"
但我不知道该怎么做。我该怎么做才能添加它,还有可能知道是and 还是or 有一个控制语句和每个不同的进程
问题已经两天了..
谢谢:)
【问题讨论】: