<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jonathan White on Medium]]></title>
        <description><![CDATA[Stories by Jonathan White on Medium]]></description>
        <link>https://medium.com/@thinkdigitalsoftware?source=rss-4b2088e44b54------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8bgdlT8rGsx_X9woJp2VxA.jpeg</url>
            <title>Stories by Jonathan White on Medium</title>
            <link>https://medium.com/@thinkdigitalsoftware?source=rss-4b2088e44b54------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:14:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thinkdigitalsoftware/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Null-aware Operators in Dart]]></title>
            <link>https://medium.com/@thinkdigitalsoftware/null-aware-operators-in-dart-53ffb8ae80bb?source=rss-4b2088e44b54------2</link>
            <guid isPermaLink="false">https://medium.com/p/53ffb8ae80bb</guid>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Jonathan White]]></dc:creator>
            <pubDate>Thu, 27 Sep 2018 18:29:28 GMT</pubDate>
            <atom:updated>2019-05-16T17:31:38.552Z</atom:updated>
            <content:encoded><![CDATA[<p>This is an updated version of Seth Ladd’s <a href="http://blog.sethladd.com/2015/07/null-aware-operators-in-dart.html">blog post</a> about Null-aware operators in Dart. Most of the content is unchanged with the exception of the examples provided at the end of the post, which help make the post easier to understand.</p><p>Null-aware operators in dart allow you to make computations based on whether or not a value is null. It’s shorthand for longer expressions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*cpTGPU8KAZo8GYZepzDLUw.png" /></figure><h3>??</h3><p>Use ?? when you want to evaluate and return an expression IFF another expression resolves to null.</p><pre>exp ?? otherExp</pre><p>is similar to</p><pre>((x) =&gt; x == null ? otherExp : x)(exp)</pre><h3>??=</h3><p>Use ??= when you want to assign a value to an object IFF that object is null. Otherwise, return the object.</p><pre>obj ??= value</pre><p>is similar to</p><pre>((x) =&gt; x == null ? obj = value : x)(obj)</pre><h3>?.</h3><p>Use ?. when you want to call a method/getter on an object IFF that object is <em>not</em> null (otherwise, return null).</p><pre>obj?.method()</pre><p>is similar to</p><pre>((x) =&gt; x == null ? null : x.method())(obj)</pre><p>You can chain ?. calls, for example:</p><pre>obj?.child?.child?.getter</pre><p>If obj, or child1, or child2 are null, the entire expression returns null. Otherwise, getter is called and returned.</p><h3><strong>Update [4/19/2019] — Dart 2.3</strong></h3><h3>?…</h3><p>Dart 2.3 brings in a <a href="https://github.com/dart-lang/sdk/blob/master/CHANGELOG.md#spread">spread operator</a> (…) and with it comes a new null aware operator, ?... !</p><blockquote>Placing ... before an expression inside a collection literal unpacks the result of the expression and inserts its elements directly inside the new collection.</blockquote><p>So now, these two are equivalent.</p><pre>List numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];</pre><p>and</p><pre>List lowerNumbers = [1, 2, 3, 4, 5];<br>List upperNumbers = [6, 7, 8, 9, 10];<br>List numbers = […lowerNumbers…upperNumbers];</pre><p>To benefit from the new null aware operator, you can use it like this.</p><pre>List lowerNumbers = [1, 2, 3, 4, 5];<br>List upperNumbers = [6, 7, 8, 9, 10];<br>List numbers = […lowerNumbers?…upperNumbers];</pre><p>which is the equivalent to</p><pre>List numbers = [];<br>numbers.addAll(lowerNumbers);<br>if(upperNumbers != null){<br> numbers.addAll(upperNumbers);<br>}</pre><h3>Try them today!</h3><p>The easiest way to try null-aware operators is to use <a href="https://dartpad.dartlang.org/">Dart Pad</a>, our browser-based playground for Dart.</p><p>Or, <a href="https://www.dartlang.org/downloads/archive/">download</a> a 1.12-dev (or later) build of the Dart SDK to try these new features in the Dart VM, dart2js, and the Dart analyzer.</p><p>Sample Code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bec68615647eb382de7302fc4b7381b4/href">https://medium.com/media/bec68615647eb382de7302fc4b7381b4/href</a></iframe><p><a href="https://dartpad.dartlang.org/2de781ac5cca62020f93271cb2df2169">Link to code on DartPad</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53ffb8ae80bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>