where-clause - 关键字 - FFL: Where vs. Let
问题描述
我试图理解以下代码:
def() ->commands
if(deferred_passive_abilities != [],
let [{ability: class passive_ability, creature: class creature}] items = [];
let found = false;
map(deferred_passive_abilities,
if(cmd = null, add(items, [value]), [cmd, set(found, true)])
where cmd = value.ability.static_effect(me, value.creature));
if(found,
set(deferred_passive_abilities, items);
evaluate_deferred_passive_abilities(),
set(deferred_passive_abilities, []))
)
Haskell 似乎同时具有let
和where
,但是通过对他们的 haskell 文档的肤浅阅读,我并没有学到很多东西。他们也有一个let...in
,我不明白,但如果 FFL 有它会很好。
那么,使用let
vs有什么意义where
呢?有必要在这里使用let
吗?(另外,可能还有另一个问题:为什么需要这些分号?)
解决方案
在这之前在FFL里从来不知道let
,肯定是非常少见的。
不管有什么见解,分号必须是绝对必要的,以便在使用绑定变量之前强制执行。换句话说,在使用分号之前,变量是不存在的。没有界限值。
where
这与不需要分号的 有很大区别。
鉴于分号不是完全适合初学者的结构,我可以向初学者推荐一些关于变量的建议,where
直到了解分号的诡计。
推荐阅读
- angular - NgRx 效果无限循环
- java - 如何通过列表
- python - CNN 过度拟合少数族裔
- python - 如何使用熊猫避免 _x _y 列
- powerbi - 将表格数据导出到excel文件
- docker - 使用 docker composer 在联网的 docker 容器中共享卷失败
- django - 如何将 Wagtail 'admin' 菜单添加到自定义模板?
- angular - Angular - 在控制台中获取json值但不在视图中
- java - 如何在 Apache Camel DSL 中回滚事务?
- spring - 主键的 Spring Data Jpa 回滚不起作用