Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "&" with no parameters

Tags:

elixir

I have this:

    case test123(&(:some_module.test456(789))) do
      # ...
    end

An error:

invalid args for &, expected an expression in the format of &Mod.fun/arity, 
&local/arity or a capture containing at least one argument as &1, 
got: :some_module.test456(789)

However, I don't have a parameter to pass into it and previously it was merely

 fn(_) -> :some_module.test456(789) end

How to fix it? Switch back to "fn"?

like image 266
Jodimoro Avatar asked May 08 '17 16:05

Jodimoro


People also ask

What kind is the word the?

The word the is considered a definite article because it defines the meaning of a noun as one particular thing. It's an article that gives a noun a definite meaning: a definite article. Generally, definite articles are used to identify nouns that the audience already knows about.

What grammatically is the word the?

Like adjectives, articles modify nouns. English has two articles: the and a/an. The is used to refer to specific or particular nouns; a/an is used to modify non-specific or non-particular nouns. We call the the definite article and a/an the indefinite article.

What is the in English word?

The (/ðə, ðiː/ ( listen)) is a grammatical article in English, denoting persons or things already mentioned, under discussion, implied or otherwise presumed familiar to listeners, readers, or speakers. It is the definite article in English.

What is a the is called?

A, An and The are called articles. They are essentially demonstrative adjectives.


1 Answers

The & syntax cannot be used to create such anonymous functions because the compiler can't know whether you wanted to create a 0 or 1 or 2 or more arity function. You'll have to keep using fn(_) -> :some_module.test456(789) end.

like image 88
Dogbert Avatar answered Sep 30 '22 06:09

Dogbert