Elixir Program Map to struct - Computer Programming


C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Thursday, September 28, 2017

Elixir Program Map to struct

Map to struct


# given the struct
defmodule User do
  defstruct username: nil

%User{username: "test" } = struct(User, %{username: "test", password: "secret"})

# struct! raises KeyError if un-matching keys provided
%User{username: "test" } = struct!(User, %{username: "test", password: "secret"})

No comments:

Post a Comment