<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="91787" data-post-id="91787">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="peerreynders" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/120/5826_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  peerreynders
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="7stud" data-post="19" data-topic="15670">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/7/57b2e6/48.png" class="avatar"> 7stud:</div>
<blockquote>
<p>I was searching for a feature that doesn’t exist, and I will have to make do.</p>
</blockquote>
</aside>
<pre data-code-wrap="irb"><code class="lang-irb">irb(main):001:0&gt; h = Hash.new {|hash, key| hash[key] = []}
=&gt; {}
irb(main):002:0&gt; h.has_key?(:a)
=&gt; false
irb(main):003:0&gt; h[:a]
=&gt; []
irb(main):004:0&gt; h.has_key?(:a)
=&gt; true
irb(main):005:0&gt; g = Hash.new([])
=&gt; {}
irb(main):006:0&gt; g.has_key?(:a)
=&gt; false
irb(main):007:0&gt; g[:a]
=&gt; []
irb(main):008:0&gt; g.has_key?(:a)
=&gt; false
irb(main):009:0&gt;
</code></pre>
<p>I think it needs to be said that <code>Hash</code> is an <em>object</em> - where behaviour and data are complected (possibly even on the instance level) - while Map is a <em>data structure</em> where the <code>Map</code> module provides the necessary functions to <em>consistently</em> manipulate that data structure.</p>
<p>So with Maps custom behaviour is either accomplished by injecting custom behaviour (under the control of the user of the data structure) functions like the <code>Access.key/2</code> example or by defining new new manipulation functions as part of a new module - possibly creating a new data structure altogether that the standard Map becomes a part of.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="91787" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/updating-a-maps-values-that-are-lists/15670/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-91787" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="91787"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="92006" data-post-id="92006">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="rvirding" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rvirding/120/1409_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  rvirding
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Erlang</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The way I interpreted what you had written was that there was an explicit value of <code>[]</code>. Seeing the docs <strong>explicitly</strong> says that the initial value is not passed into the fun [*] it seemed a reasonable way of interpreting it. Sorry if I was wrong.</p>
<p>[*] Whether this is a good choice or not is another question.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="92006" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/updating-a-maps-values-that-are-lists/15670/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-92006" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="92006"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="92014" data-post-id="92014">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Ryzey" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Ryzey/120/17302_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Ryzey
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The definition for Map.update is<br>
<code>def update(map, key, initial, fun) when is_function(fun, 1)</code> where <code>fun</code> is a 1 arity function that receives the existing value.</p>
<p>I don’t think it would be a breaking change to add this definition:<br>
<code>def update(map, key, initial, fun) when is_function(fun, 2)</code> where <code>fun</code> is a 2 arity function that receives the existing value <em>and</em> the <code>initial</code> value. By <code>initial</code> value, I mean the value that the user supplied as the 3rd argument.</p>
<p>The second definition is what I expected the functionality of update to be and what I would prefer (and I think this is what <a class="mention" href="/u/7stud" rel="nofollow">@7stud</a> and <a class="mention" href="/u/overminddl1" rel="nofollow">@OvermindDL1</a> would prefer). Importantly, there would be no impact for anyone who did not want to use the <code>initial</code> value in <code>fun</code>. They could simply continue to provide a 1 arity function as <code>fun</code>.</p>
<p>As <a class="mention" href="/u/overminddl1" rel="nofollow">@overmindDL1</a> points out, there are options to work around this limitation, but I agree with <a class="mention" href="/u/7stud" rel="nofollow">@7stud</a> that this is an oversight.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="92014" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/updating-a-maps-values-that-are-lists/15670/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-92014" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="92014"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>