Skip to content

Commit

Permalink
Merge pull request elixir-lang#3245 from whatyouhide/defstruct-docs
Browse files Browse the repository at this point in the history
Add some docs to `defstruct/1`
  • Loading branch information
josevalim committed Apr 6, 2015
2 parents 4981160 + 4b7c2a6 commit 775d3f0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/elixir/lib/kernel.ex
Expand Up @@ -3015,6 +3015,15 @@ defmodule Kernel do
defstruct name: nil, age: 10 + 11
end
The `fields` argument is usually a keyword list with fields as keys and
default values as corresponding values. `defstruct/1` also supports a list of
atoms as its argument: in that case, the atoms in the list will be used as
the struct's fields and they will all default to `nil`.
defmodule Post do
defstruct [:title, :content, :author]
end
## Deriving
Although structs are maps, by default structs do not implement
Expand Down

0 comments on commit 775d3f0

Please sign in to comment.