Enum frequencies - error UndefinedFunctionError

Viewed 243

I am trying to use Enum function frequencies but it isn't work. Base on documentation Enum - Elixir v1.10.2

When I try to use that example:

Enum.frequencies(~w{ant buffalo ant ant buffalo dingo})
# OR
Enum.frequencies(["ant", "buffalo", "ant", "ant", "buffalo", "dingo"])

I always revive error:

** (UndefinedFunctionError) function Enum.frequencies/1 is undefined or private

I have already tried to execute that code example at iex shell, .ex file body and online Repl.

My local elixir version Elixir 1.9.4 (compiled with Erlang/OTP 22)

It seems to me that I miss some essential point at documentation, so I am looking for some pro tip ;)

1 Answers

The documentation what you provided is describes Elixir v1.10.2 but you use Elixir 1.9.4. Looks like the function Enum.frequencies/1 is not exist in Elixir 1.9.4 at all and this function was added in version 1.10.0 and higher. By this reason you see error. I suppose, if you need to use Enum.frequencies/1, you need upgrade Elixir to latest version or at least until of version 1.10.0.

Related