small medium large xlarge

02 Jun 2014, 17:51
Alex Kaplan (1 post)

Book version: B13.3.13.3—May 27, 2014

While using Elixir 0.13.3, the code snippets below are the only way that I could figure out how to achieve the record manipulation examples from the book. Possibly due to records needing to be declared inside of modules and general updates to Record API:

iex(17)> require Record
iex(18)> defmodule User do
...(18)> Record.defrecord :phone, country: "1", area: "555", local: nil
...(18)> end
iex(19)> require User

To create a new record with default values

iex> number1 =

To create a new record with prepopulated values

iex> number2 = "1212", country: "44")

To get a specific field in a record

iex> c =, :country)

To update a value in a record

iex>, country: "+" <>, :country))



  You must be logged in to comment