Enum.map is passing elements of the map as a single argument - a {key, value} tuple. The fn version pattern-matches on that to extract the second element.
To do this with &, you’ll need to use elem explicitly:
I will do it like this: a1 = Enum.map(m1,&elme(&1,1)) & in some way like Function.bind in js, but I comfused by why can not reference a named function just by it’s name, but must do like &String.length/1.
So, as you can probably see, simply “referencing” a function without parens also calls it.
To add to the short answer, and this is a thing that comes up all the time so it’s very easy to google more info about (and I sincerely don’t mean that in a RTMF way), functions are referenced by both their name and their arity.
A quick example:
defmodule Math do
def add(a, b) do
a + b
end
def add(a, b, c) do
a + b + c
end
end
Under the hood, add(a, b) and add(a, b, c) are compiled as completely separate and wholly unrelated functions. The /1 in your example denotes that you are calling the function named length with a single argument (that’s the /1 part) on the String module.