Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error in readme example #26

@joaothallis

Description

@joaothallis

This:

/app # iex -S mix
Erlang/OTP 21 [erts-10.3.5.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> defmodule TestStruct do
...(1)>   defstruct field_one: nil,
...(1)>             field_two: nil,
...(1)>             field_three: nil,
...(1)>             field_four: nil
...(1)>   use ExConstructor
...(1)> end
{:module, TestStruct,
 <<70, 79, 82, 49, 0, 0, 7, 224, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 249,
   0, 0, 0, 23, 17, 69, 108, 105, 120, 105, 114, 46, 84, 101, 115, 116, 83, 116,
   114, 117, 99, 116, 8, 95, 95, 105, 110, ...>>, :ok}
iex(2)> 
nil
iex(3)> TestStruct.new(%{"field_one" => "a", "fieldTwo" => "b", :field_three => "c", :FieldFour => "d"})
%TestStruct{field_four: nil, field_one: "a", field_three: "c", field_two: "b"}

Expect: %TestStruct{field_one: "a", field_two: "b", field_three: "c", field_four: "d"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions