<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: TIP: (Safely) Concatenating Strings that might be NULL in Workato Pros Discussion Board</title>
    <link>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12174#M4674</link>
    <description>&lt;P&gt;Oh, I almost forgot the safety operator. When you have a variable that might be nil, you can use the safety operator (&amp;amp;) to skip calling the method entirely. I use this on pretty much every inline Ruby I write these days.&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;## bad news bears
array = nil
nil.where(x: true) ## error, no method .where for nil

## safety operator &amp;amp;
array = nil
nil&amp;amp;.where(x: true) ## returns null, no error&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 May 2026 17:34:45 GMT</pubDate>
    <dc:creator>gary1</dc:creator>
    <dc:date>2026-05-08T17:34:45Z</dc:date>
    <item>
      <title>TIP: (Safely) Concatenating Strings that might be NULL</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12171#M4671</link>
      <description>&lt;P&gt;I was today years old when I came across this simple solution so thought I'd post it!&lt;/P&gt;&lt;P&gt;I often find I want to concatenate two or more strings together, usually when trying to formulate a friendly error message for a log or an email to a human when something's not quite worked right.&lt;/P&gt;&lt;P&gt;However, you can't safely just use...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="no conv.jpg" style="width: 353px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/2672i1972C45EF76643F6/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="no conv.jpg" alt="no conv.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;... because if either or both values contains a NULL, Workato throws an error.&lt;/P&gt;&lt;P&gt;I started to head down the ternary operator route (which felt overly complicated and difficult to read) and then stumbled across the use of ".to_s" for each data pill to force convert the data pill to a string...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="to_s.jpg" style="width: 418px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/2671i55C81E03D721315E/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="to_s.jpg" alt="to_s.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, if either value contains NULL the result is an empty string (which Workato is then happy to "squish" with another string).&lt;/P&gt;&lt;P&gt;Realise it's very basic, but thought I'd share in case someone else might find it useful.&lt;/P&gt;&lt;P&gt;Tune in next week for "Russell learns to pat his head and rub his tummy at the same time"...&lt;/P&gt;&lt;P&gt;[waits for &lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/1188"&gt;@gary1&lt;/a&gt;&amp;nbsp;&amp;nbsp;to jump in with an even better, more elegant solution...]&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2026 10:11:26 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12171#M4671</guid>
      <dc:creator>RussellJ</dc:creator>
      <dc:date>2026-05-08T10:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: TIP: (Safely) Concatenating Strings that might be NULL</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12172#M4672</link>
      <description>&lt;P&gt;This is actually pretty interesting. I figured .to_s would error out on nil.&lt;/P&gt;&lt;P&gt;My preferred way is:&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;[$string1, $string2].smart_join("") ## use any delimiter you want

## the above is essentially the same as the below
[$string1, $string2].compact.join("")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2026 16:12:22 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12172#M4672</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2026-05-08T16:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: TIP: (Safely) Concatenating Strings that might be NULL</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12173#M4673</link>
      <description>&lt;P&gt;{faints}&lt;/P&gt;&lt;P&gt;I did consider smart_join but prefer the really clean .to_s, but hadn't come across compact before - thanks!&lt;/P&gt;&lt;P&gt;I might start reading an alphabetical list of workato allowed functions in case there's anything else of interest (after all that's how I first learned BASIC on my ZX81... the manual for which someone has kindly &lt;A href="https://www.retroisle.com/sinclair/zx81/OriginalDocs/zx81manual.php" target="_self"&gt;made available online&lt;/A&gt; &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;).&lt;/P&gt;&lt;P&gt;Happy Friday.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2026 16:54:19 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12173#M4673</guid>
      <dc:creator>RussellJ</dc:creator>
      <dc:date>2026-05-08T16:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: TIP: (Safely) Concatenating Strings that might be NULL</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12174#M4674</link>
      <description>&lt;P&gt;Oh, I almost forgot the safety operator. When you have a variable that might be nil, you can use the safety operator (&amp;amp;) to skip calling the method entirely. I use this on pretty much every inline Ruby I write these days.&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;## bad news bears
array = nil
nil.where(x: true) ## error, no method .where for nil

## safety operator &amp;amp;
array = nil
nil&amp;amp;.where(x: true) ## returns null, no error&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2026 17:34:45 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/tip-safely-concatenating-strings-that-might-be-null/m-p/12174#M4674</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2026-05-08T17:34:45Z</dc:date>
    </item>
  </channel>
</rss>

