elixir-lang/elixir — pull request #312 by yrashk (2012-05-29 21:32:47+00:00)
Title: Adds `to_keyword(record)` function to all records

This function can be used to convert any record to a Keyword:

iex> defrecord A, a: 1, b: 2, c: nil
nil
iex> A.new
A[a: 1, b: 2, c: nil]
iex> A.new.to_keyword
[{:a,1},{:b,2},{:c,nil}]
iex> A.new(c: "a").to_keyword
[{:a,1},{:b,2},{:c,"a"}]