title: Erlang pattern matching of a list of records on receive
body: <p>I'm trying to create a generic receive for a part of my app that requires to wait for several updates at different times.<br>
  This is the prototype that it is not working.</p>
  
  <pre><code>receive_info([])-&gt;[];
  receive_info([RequiredInfo|RestRequiredInfos]) -&gt;
    receive
      RequiredInfo -&gt; [ RequiredInfo | receie_info(RestRequiredInfos)];
    end.
  </code></pre>
  
  <p>And it is getting called as  </p>
  
  <pre><code>[UserInfo, ContextInfo] = receive_info([#userinfo{},#contextinfo{}]),
  </code></pre>
  
  <p>So, what I'm trying is to send a list of record types it should match and I expect a list of records received.<br>
  Not sure if this is doable, because the records set their fields to undefined and the pattern matching does not work, for example:   </p>
  
  <pre><code>Trying to receive {user_info,undefined}
  Other clause: instead {user_info,12} received
  </code></pre>
  
  <p><strong>EDIT:</strong><br>
  As <code>is_record</code> version supplied by @Adam Lindberg was not working for me I followed a bit that same way of doing things and I ended up with:   </p>
  
  <pre><code>receive_infos([]) -&gt; [];
  receive_infos([Rec|Records]) -&gt;
  receive
      %% Guard expression that compares first element in record with supplied record tag
      Record when element(1, Record) =:= Rec -&gt; 
          [ Record | receive_infos(Records)]
  end.
  </code></pre>