Add Map.from_struct and Kernel.struct to maps section of Elixir cheatsheet (#1631)

* Update elixir.md

Added Map.from_struct and Kernel.struct to maps section.

* Update elixir.md

Co-authored-by: Rico Sta. Cruz <rstacruz@users.noreply.github.com>
This commit is contained in:
Pedro Assunção 2021-03-16 01:01:25 +00:00 committed by GitHub
parent 4d47cbd4e9
commit c1de0e223c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -429,6 +429,20 @@ Map.new([a: 1, b: 2])
Map.new([:a, :b], fn x -> {x, x} end) # → %{a: :a, b: :b}
```
### Working with structs
#### Struct to map
```elixir
Map.from_struct(%AnyStruct{a: "b"}) # → %{a: "b"}
```
#### Map to struct
```elixir
struct(AnyStruct, %{a: "b"}) # → %AnyStruct{a: "b"}
```
## List
```elixir