[英]FunctionClauseError when calling :wxFrame.new from Elixir
I have just two questions :) 我只有两个问题:)
Elixir code: 药剂代码:
import WxConstants
...
wx = :wx.new
frame = :wxFrame.new(wx, wxID_ANY, "Game of Life", size: {500, 500})
Output: 输出:
** (FunctionClauseError) no function clause matching in :wxFrame.new/4
gen/wxFrame.erl:111: :wxFrame.new({:wx_ref, 0, :wx, []}, -1, "Game of Life", [size: {500, 500}])
WxConstants module: https://github.com/ElixirWin/wxElixir WxConstants模块: https : //github.com/ElixirWin/wxElixir
Dogbert had already answered the first question, I would answer the second one. Dogbert已经回答了第一个问题,我会回答第二个问题。
** (FunctionClauseError) no function clause matching in ... **(FunctionClauseError)在...中没有匹配的功能子句
is one of the most frequently happening errors in Elixir, as well as any other language supporting pattern matching in function clauses. 是Elixir以及其他任何支持函数子句中模式匹配的语言中最常见的错误之一。 Consider this contrived example: 考虑这个人为的例子:
defmodule M do
def test(param) when is_binary(param), do: "binary"
def test(param) when is_list(param), do: "list"
end
M.test("Hello, world")
#⇒ "binary"
M.test([1, 2, 3])
#⇒ "list"
When there is no function clause, that could be matched against the parameters given, the error above happens: 如果没有可以与给定参数匹配的函数子句,则会发生上述错误:
M.test(42)
#⇒ ** (FunctionClauseError) no function clause matching in M.test/1
That said, the library, you are using, expected other type(s) of one or many parameters. 就是说,您正在使用的库期望使用其他类型的一个或多个参数。 Let's check: :wxFrame.new/4
expects: 让我们检查一下:wxFrame.new/4
期望:
Parent = wxWindow:wxWindow()
Id = integer()
Title = unicode:chardata()
Option = {pos, {X::integer(), Y::integer()}} |
{size, {W::integer(), H::integer()}} |
{style, integer()}
The third parameter is expected to be unicode:chardata()
which is in turn Erlang charlist, that is denoted in Elixir by single quotes. 第三个参数应该是unicode:chardata()
,它依次是Erlang字符列表,在Elixir中用单引号表示。 Hence the comment by @Dogbert: use single quotes around ' Game of Life'
. 因此,@ Dogbert的评论:在“ Game of Life'
周围使用单引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.