ankush981
ankush981

Reputation: 5407

ETS table creation error

I've run into a problem when trying to create and ETS table based on records. The code is taken from the book Introducing Elixir.

Here's the record:

defmodule Planemo do
    require Record
    Record.defrecord :planemo, [name: nil, gravity: 0, diameter: 0, distance_from_sun: 0]
end

Now if a table is created as follow, it succeeds:

planemo_table = :ets.new(:planemos,[:named_table, {:keypos, Planemo.planemo(:name) + 1}])

In another example, the author uses the following syntax (__record__) and it fails:

planemo_table = :ets.new(:planemos,[:named_table, {:keypos, Planemo.__record__(:index, :name) + 1}])

Error:

** (UndefinedFunctionError) function Planemo.__record__/2 is undefined or private
    Planemo.__record__(:index, :name)
    planemo_storage.ex:6: PlanemoStorage.setup/0

I first thought that maybe __record__ was deprecated in Elixir 1.3.2, but I've not been able to find any trace of it. Please help.

Upvotes: 2

Views: 88

Answers (1)

Dogbert
Dogbert

Reputation: 222090

That book seems to be very old. Many of the Records features including __record__ were removed on 24 May 2014 and the change was part of Elixir 0.14 which was released on 17 June 2014.

Upvotes: 1

Related Questions