iex>1= x1iex>2= x** (MatchError) no match of right hand side value: 1
然后试一些刚学过的集合类型:
# Listsiex> list = [1,2,3]iex> [1,2,3] = list[1,2,3]iex> [] = list** (MatchError) no match of right hand side value: [1,2,3]iex> [1| tail] = list[1,2,3]iex> tail[2,3]iex> [2|_] = list** (MatchError) no match of right hand side value: [1,2,3]# Tuplesiex> {:ok, value} = {:ok,"Successful!"}{:ok,"Successful!"}iex> value"Successful!"iex> {:ok, value} = {:error}** (MatchError) no match of right hand side value: {:error}
iex> key ="hello""hello"iex> %{^key => value} = %{"hello"=>"world"}%{"hello"=>"world"}iex> value"world"iex> %{^key => value} = %{:hello =>"world"}** (MatchError) no match of right hand side value: %{hello: "world"}