title: update a List with structs Elixir
body: <p>I have an an object as </p>
  
  <pre><code>%{
    shares: []
  }
  </code></pre>
  
  <p>I want to add a struct <code>%Cs{name: "Junaid1"}</code>, <code>%Cs{name: "Junaid2"}</code> into the list through <code>Enum.each</code> or <code>map</code>, is that possible to do?</p>
  
  <p>Okay for just more brief I am updating question again..</p>
  
  <pre><code> Enum.each(email_array, fn (email) -&gt;
      with {:found_user, sharee} &lt;- ensure_user(email)
      do
        case CameraShare.create_share(camera, sharee, caller, params["rights"], params["message"]) do
          {:ok, camera_share} -&gt;
             #Add camera_share to list
          {:error, changeset} -&gt;
            #Add error to a list
        end
      else
        {:not_found, email} -&gt;
          case CameraShareRequest.create_share_request(camera, email, caller, params["rights"], params["message"]) do
            {:ok, camera_share_request} -&gt;
              #Add camera_share to list
            {:error, changeset} -&gt;
              #Add error to list
          end
      end
    end)
  </code></pre>
  
  <p>and then at the end of Enum.each.. there will be a map as </p>
  
  <pre><code>%{
     shares: [all shares],
     errors: [all errors]
  }
  </code></pre>
  
  <p>where as each share is of type <code>%CameraShare{__meta__: #Ecto.Schema.Metadata&lt;:loaded, "camera_shares"&gt;}</code></p>