Skip to content

Commit 69b78da

Browse files
author
José Valim
committed
Update docs and CHANGELOG
1 parent 0685e03 commit 69b78da

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* [Mix] Use absolute symbolic links on Windows for `_build` instead of copying
1212
* [Mix] Add `Mix.compilers` that returns all default compilers used by mix tasks
1313
* [Mix] Issue warning and reset mtime for source files from the future
14+
* [Mix] Support task aliases in Mix
15+
* [OptionParser] Add `OptionParser.split/1` that splits a string into argv
16+
* [Record] Allow a record to be converted to a keyword list with `record(some_record)`
1417
* [String] Improve performance of `String.split/1`
1518
* [Typespec] Allow `%Struct{}` syntax to be used in typespecs
1619

lib/elixir/lib/record.ex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,18 @@ defmodule Record do
119119
arities will be defined to manipulate the underlying record:
120120
121121
# To create records
122-
user() #=> {:user, "José", 25}
123-
user(age: 26) #=> {:user, "José", 26}
122+
record = user() #=> {:user, "José", 25}
123+
record = user(age: 26) #=> {:user, "José", 26}
124124
125125
# To get a field from the record
126126
user(record, :name) #=> "José"
127127
128128
# To update the record
129129
user(record, age: 26) #=> {:user, "José", 26}
130130
131+
# Convert a record to a keyword list
132+
user(record) #=> [name: "José", age: 26]
133+
131134
By default, Elixir uses the record name as the first element of
132135
the tuple (the tag). But it can be changed to something else:
133136
@@ -192,9 +195,7 @@ defmodule Record do
192195
Keyword.keyword?(args) ->
193196
create(atom, fields, args, caller)
194197
true ->
195-
quote bind_quoted: [atom: atom, fields: fields, args: args] do
196-
Record.__keyword__(atom, fields, args)
197-
end
198+
quote do: Record.__keyword__(unquote(atom), unquote(fields), unquote(args))
198199
end
199200
end
200201

0 commit comments

Comments
 (0)