【发布时间】:2019-02-26 16:29:35
【问题描述】:
我目前正在用 Elixir 编写一个小测试运行程序。我想使用模式匹配来评估文件是否采用规范格式(以“_spec.exs”结尾)。有许多关于如何在字符串开头进行模式匹配的教程,但不知何故不适用于字符串结尾:
defp filter_spec(file <> "_spec.exs") do
run_spec(file)
end
defp run_spec(file) do
...
end
这总是以编译错误结束:
== Compilation error on file lib/monitor.ex ==
** (CompileError) lib/monitor.ex:13: a binary field without size is only allowed at the end of a binary pattern
(stdlib) lists.erl:1337: :lists.foreach/2
(stdlib) erl_eval.erl:669: :erl_eval.do_apply/6
有什么解决办法吗?
【问题讨论】:
标签: elixir