July 2017
Intermediate to advanced
284 pages
6h 45m
English
We had a pleasant surprise when we built this API. We’d accidentally built in support for structs! Since an Elixir struct is just a map with the extra __struct__ key, just adding the key __struct__: User to the existing User record would create users that satisfy a struct called User like this:
| | ~~~ |
| | register :user, |
| | __struct__: User, |
| | first_name: Faker.Name.first_name, |
| | last_name: Faker.Name.last_name, |
| | email: Sequence.next(:email, &"test#{&1}@example.com") |
| | ~~~ |
Read now
Unlock full access