<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 11 Feb 2017, at 18:33, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" class="">dabrahams@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">All of these examples should be efficiently and expressively handled by the pattern matching API mentioned in the proposal. They definitely do not require random access or integer indexing.&nbsp;<br class=""><br class=""></div></div></div></blockquote><div>Hi Dave,&nbsp;</div><div>then I am very interested to know how to unpack aString (e.g. read from a file record such as in the previous example:</div><div>123534-09EVXD4568,991234,89ABCYELLOW12AGRAINESYTEMZ3453 )&nbsp;</div><div>without using direct subscripting like str[n1…n2) ?&nbsp;</div><div>(which btw is for me the most straightforward and ideal method)&nbsp;</div><div>conditions:</div><div>&nbsp; &nbsp;-The source string contains fields of known position (offset) and length, concatenated together</div><div>&nbsp; &nbsp; without any separators (like in a CSV)</div><div>&nbsp; -the &nbsp;contents of each field is unpredictable.&nbsp;</div><div>&nbsp; &nbsp;which excludes the use of pattern-matching.&nbsp;</div><div>&nbsp; &nbsp;-the source string needs to be unpacked in independent strings.&nbsp;</div><div><br class=""></div><div>I made this example: (the comments also stress my point)&nbsp;</div><div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">//: Playground - noun: a place outside the mean and harsh production environment</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class="">// &nbsp; No presidents were harmed during the production of this example.&nbsp;</div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">import</span><span style="font-variant-ligatures: no-common-ligatures" class=""> UIKit</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">import</span><span style="font-variant-ligatures: no-common-ligatures" class=""> Foundation</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// The following String extension with subscriptor "direct access"</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// functionality, included in in almost each and every app I create,</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// wouldn't be necessary if str[a..&lt;b] was an integral part of Swift strings!</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">//</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// However when str[a..&lt;b] would or will be implemented into Swift,</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// then, by all means, make sure in the documentation, notably the</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// Swift language manual, that any string-element position and count</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// does not necessarely correspond 1:1 with the positions and length</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// on a graphical presentation devices, e.g. like dispays and printers.</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">//</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// Leave it to the programmer to decide, wether or not to use</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// direct subscripting like str[a..&lt;b].</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// as -in most cases- it only makes sense where fixed length characters</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// are used, like in the example below.</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">//</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// Like in any other programming language, an important focus should be</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// to make things as intuitively simple as possible as this:</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// - reduces and prevents errors caused by indirect programming</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// - also note that it might reduce the risk of the normally&nbsp;</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// &nbsp; very friendly but mostly stressful guys of the maintenance&nbsp;</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// &nbsp; department coming after you with dangerous intentions...</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">subscript</span><span style="font-variant-ligatures: no-common-ligatures" class="">(i: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">guard</span><span style="font-variant-ligatures: no-common-ligatures" class=""> i &gt;= </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">&amp;&amp;</span><span style="font-variant-ligatures: no-common-ligatures" class=""> i &lt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">characters</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">count</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">else</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">index</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">startIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">, offsetBy: i)])</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><p style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">subscript</span><span style="font-variant-ligatures: no-common-ligatures" class="">(range: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Range</span><span style="font-variant-ligatures: no-common-ligatures" class="">&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">&gt;) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lowerIndex = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">index</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">startIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">, offsetBy: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">max</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class="">,range.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">lowerBound</span><span style="font-variant-ligatures: no-common-ligatures" class="">), limitedBy: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">) ?? </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">substring</span><span style="font-variant-ligatures: no-common-ligatures" class="">(with: lowerIndex..&lt;(</span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">index</span><span style="font-variant-ligatures: no-common-ligatures" class="">(lowerIndex, offsetBy: range.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">upperBound</span><span style="font-variant-ligatures: no-common-ligatures" class=""> - range.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">lowerBound</span><span style="font-variant-ligatures: no-common-ligatures" class="">, limitedBy: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">) ?? </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">))</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><p style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;</span><br class="webkit-block-placeholder"></p><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">subscript</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(range: </span><span style="font-variant-ligatures: no-common-ligatures" class="">ClosedRange</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&lt;</span><span style="font-variant-ligatures: no-common-ligatures" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&gt;) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures" class="">String</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lowerIndex = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">index</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">startIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">, offsetBy: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">max</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class="">,range.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">lowerBound</span><span style="font-variant-ligatures: no-common-ligatures" class="">), limitedBy: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">) ?? </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">substring</span><span style="font-variant-ligatures: no-common-ligatures" class="">(with: lowerIndex..&lt;(</span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">index</span><span style="font-variant-ligatures: no-common-ligatures" class="">(lowerIndex, offsetBy: range.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">upperBound</span><span style="font-variant-ligatures: no-common-ligatures" class=""> - range.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">lowerBound</span><span style="font-variant-ligatures: no-common-ligatures" class=""> + </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span><span style="font-variant-ligatures: no-common-ligatures" class="">, limitedBy: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">) ?? </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span><span style="font-variant-ligatures: no-common-ligatures" class="">))</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// In the following example, the record's field positions and lengths are fixed format</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// and will never change.</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// Also, the record's contents has been validated completely by the sending application.</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// Normally it is an input record, read from a storage medium,</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// however for the purpose of this example it is defined here:</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> record = </span><span style="font-variant-ligatures: no-common-ligatures" class="">"123A.534.CMCU3Arduino Due &nbsp; &nbsp; Arm 32-bit Micro controller.&nbsp; 000000034100000005680000002250$"</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// Define a product data structure:</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures" class=""> Product</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> id :</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class=""> &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// is key</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> group: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> name: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> description : </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> inStock: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ordered : </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> price: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// in cents: no Money data type in Swift available.</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> currency: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><p style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// of course one could use "set/get" properties here</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// which could validate the input to this structure.</span></div><p style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> priceFormatted: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// computed property.</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">get</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> whole = (</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">price</span><span style="font-variant-ligatures: no-common-ligatures" class=""> / </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">100</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> cents = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">price</span><span style="font-variant-ligatures: no-common-ligatures" class=""> - (whole * </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">100</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">currency</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">+</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">" </span><span style="font-variant-ligatures: no-common-ligatures" class="">\</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">whole</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">).</span><span style="font-variant-ligatures: no-common-ligatures" class="">\</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">cents</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">)"</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><p style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// TODO: disable other default initiators.</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(inputrecord: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp; &nbsp; inputrecord</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">[</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">10</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">]</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">group</span><span style="font-variant-ligatures: no-common-ligatures" class=""> &nbsp; &nbsp; &nbsp; = &nbsp; &nbsp; inputrecord</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">10</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">14</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">]</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">name</span><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; = &nbsp; &nbsp; inputrecord</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">14</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">30</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">]</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">description</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = &nbsp; &nbsp; inputrecord</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">30</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">60</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">]</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">inStock</span><span style="font-variant-ligatures: no-common-ligatures" class=""> &nbsp; &nbsp; = </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">(inputrecord</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">60</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">70</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">]</span><span style="font-variant-ligatures: no-common-ligatures" class="">)!</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ordered</span><span style="font-variant-ligatures: no-common-ligatures" class=""> &nbsp; &nbsp; = </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">(inputrecord</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">70</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">80</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">]</span><span style="font-variant-ligatures: no-common-ligatures" class="">)!</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">price</span><span style="font-variant-ligatures: no-common-ligatures" class=""> &nbsp; &nbsp; &nbsp; = </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">(inputrecord</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">80</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">90</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">]</span><span style="font-variant-ligatures: no-common-ligatures" class="">)!</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">currency</span><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; = &nbsp; &nbsp; inputrecord</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">90</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">]</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><p style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// Add necessary business and DB logic for products here.</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> test()</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> product = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Product</span><span style="font-variant-ligatures: no-common-ligatures" class="">(inputrecord: </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">record</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"=== Product data for the item with ID: </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">product.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span><span style="font-variant-ligatures: no-common-ligatures" class="">) ===="</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">product.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span><span style="font-variant-ligatures: no-common-ligatures" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"group&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">product.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">group</span><span style="font-variant-ligatures: no-common-ligatures" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">product.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">name</span><span style="font-variant-ligatures: no-common-ligatures" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"description&nbsp; &nbsp; : </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">product.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">description</span><span style="font-variant-ligatures: no-common-ligatures" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"items in stock : </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">product.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">inStock</span><span style="font-variant-ligatures: no-common-ligatures" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"items ordered&nbsp; : </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">product.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ordered</span><span style="font-variant-ligatures: no-common-ligatures" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"price per item : </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">product.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">priceFormatted</span><span style="font-variant-ligatures: no-common-ligatures" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"========================================================="</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">test</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()</span></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class="">Which emitted the following output</div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">=== Product data for the item with ID 123A.534.C ====</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : 123A.534.C</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">group&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : MCU3</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : Arduino Due&nbsp; &nbsp; &nbsp;</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">description&nbsp; &nbsp; : Arm 32-bit Micro controller. &nbsp;</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">items in stock : 341</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">items ordered&nbsp; : 568</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">price per item : $ 22.50</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">====================================================</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">Isn’t that an elegant solution or what?&nbsp;</div></div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">I might start a very lengthy discussion here about the threshold of where and how</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">to protect the average programmer (like me :o) from falling in to language pittfalls</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">and to what extend these have effect on working with a PL. One cannot make</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">a PL idiot-proof. Of course, i agree a lot of it make sense, and also the “intelligence”</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">of the Swift compiler (sometimes it almost feels as if it sits next to me looking at</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">the screen and shaking its head from time to time) But hey, remember most of</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">us in our profession have a brain too.&nbsp;</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">(btw, if you now of a way to let Xcode respect in-between spaces when auto-formatting please let me know, thanks)</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class=""><br class=""></div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">@Ben Cohen:</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">Hi, you wrote:</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class=""><span style="font-family: Avenir-Medium;" class="">"p.s. as someone who has worked in a bank with thousands of ancient file formats, no argument from me that COBOL rules :)"</span></div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">Although still the most part of accounting software is Cobol (mostly because it is too expensive&nbsp;</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">and risky to convert to newer technologies) I don’t think that Cobol rules and that new apps definitely should</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">not be written in Cobol. I wouldn’t be doing Swift if I thought otherwise. &nbsp;</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">If I would be doing a Cobol project again, It would be with same enjoyment as say,</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">a 2017 mechanical engineer, working on a steam locomotive of a touristic railroad.</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">which I would do with dedication as well. However, never use this comparison</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">at the hiring interview..:o)</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class=""><br class=""></div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class=""><br class=""></div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">Kind Regards</div><div style="font-family: Avenir; font-size: 14px; margin: 0px; line-height: normal; min-height: 21px;" class="">TedvG</div><div class=""><br class=""></div></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="font-family: Menlo; font-size: 18px; margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div></div></div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><div class="">Sent from my moss-covered three-handled family gradunza</div></div><div class=""><br class="">On Feb 9, 2017, at 5:09 PM, Ted F.A. van Gaalen &lt;<a href="mailto:tedvgiosdev@gmail.com" class="">tedvgiosdev@gmail.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 10 Feb 2017, at 00:11, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" class="">dabrahams@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">on Thu Feb 09 2017, "Ted F.A. van Gaalen" &lt;<a href="http://tedvgiosdev-at-gmail.com/" class="">tedvgiosdev-AT-gmail.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">Hello Shawn<br class="">Just google with any programming language name and “string manipulation”<br class="">and you have enough reading for a week or so :o)<br class="">TedvG<br class=""></blockquote><br class="">That truly doesn't answer the question. &nbsp;It's not, “why do people index<br class="">strings with integers when that's the only tool they are given for<br class="">decomposing strings?” &nbsp;It's, “what do you have to do with strings that's<br class="">hard in Swift *because* you can't index them with integers?”<br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">Hi Dave,</div><div class="">Ok. here are just a few examples:&nbsp;</div>Parsing and validating an ISBN code? or a (freight) container ID? or EAN13 perhaps?&nbsp;</div><div class="">of many of the typical combined article codes and product IDs that many factories and shops use?&nbsp;</div><div class=""><br class=""></div><div class="">or:&nbsp;</div><div class=""><br class=""></div><div class="">E.g. processing legacy files from IBM mainframes:</div><div class="">extract fields from ancient data records read from very old sequential files,</div><div class="">say, a product data record like this from a file from 1978 you’d have to unpack and process: &nbsp;&nbsp;</div><div class="">123534-09EVXD4568,991234,89ABCYELLOW12AGRAINESYTEMZ3453</div><div class="">into:</div><div class="">123, 534, -09, EVXD45, 68,99, 1234,99, ABC, YELLOW, 12A, GRAIN, ESYSTEM, Z3453.</div><div class="">product category, pcs, discount code, product code, price Yen, price $, class code, etc…&nbsp;</div><div class="">in Cobol and PL/1 records are nearly always defined with a fixed field layout like this.:</div><div class="">(storage was limited and very, very expensive, e.g. XML would be regarded as a&nbsp;</div><div class="">"scandalous waste" even the commas in CSV files! )&nbsp;</div><div class=""><br class=""></div><div class="">01 &nbsp;MAILING-RECORD.</div><pre class=""><div class="">&nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;COMPANY-NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PIC X(30).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;CONTACTS.</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10 &nbsp;PRESIDENT.</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;15 &nbsp;LAST-NAME &nbsp; &nbsp; &nbsp; PIC X(15).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;15 &nbsp;FIRST-NAME &nbsp; &nbsp; &nbsp;PIC X(8).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10 &nbsp;VP-MARKETING.</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;15 &nbsp;LAST-NAME &nbsp; &nbsp; &nbsp; PIC X(15).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;15 &nbsp;FIRST-NAME &nbsp; &nbsp; &nbsp;PIC X(8).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10 &nbsp;ALTERNATE-CONTACT.</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;15 &nbsp;TITLE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PIC X(10).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;15 &nbsp;LAST-NAME &nbsp; &nbsp; &nbsp; PIC X(15).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;15 &nbsp;FIRST-NAME &nbsp; &nbsp; &nbsp;PIC X(8).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;ADDRESS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PIC X(15).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;CITY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PIC X(15).</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;STATE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PIC XX.</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;ZIP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PIC 9(5).</div><div class=""><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">These are all character data fields here, except for the numeric ZIP field , however in Cobol it can be treated like character data.&nbsp;</div><div style="font-family: Avenir; white-space: normal;" class=""><div class="">So here I am, having to get the data of these old Cobol production files</div><div class="">into a brand new Swift based accounting system of 2017, what can I do? &nbsp;&nbsp;</div><div class=""><br class=""></div><div class="">How do I unpack these records and being the data into a Swift structure or class?&nbsp;</div><div class="">(In Cobol I don’t have to because of the predefined fixed format record layout).</div></div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">AFAIK there are no similar record structures with fixed fields like this available Swift?</div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">So, the only way I can think of right now is to do it like this:</div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">// mailingRecord is a Swift structure</div><div style="font-family: Avenir; white-space: normal;" class="">struct MailingRecord</div><div style="font-family: Avenir; white-space: normal;" class="">{</div><div style="font-family: Avenir; white-space: normal;" class="">&nbsp; &nbsp; var &nbsp;companyName: String = “no Name”</div><div style="font-family: Avenir; white-space: normal;" class="">&nbsp; &nbsp; &nbsp;var contacts: CompanyContacts</div><div style="font-family: Avenir; white-space: normal;" class="">&nbsp; &nbsp; &nbsp;.</div><div style="font-family: Avenir; white-space: normal;" class="">&nbsp; &nbsp; &nbsp;etc..&nbsp;</div><div style="font-family: Avenir; white-space: normal;" class="">}</div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">// recordStr was read here with ASCII encoding</div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">// unpack data in to structure’s properties, in this case all are Strings</div><div style="font-family: Avenir; white-space: normal;" class="">mailingRecord.companyName &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = recordStr[ 0..&lt;30]</div><div style="font-family: Avenir; white-space: normal;" class="">mailingRecord.contacts.president.lastName &nbsp;= recordStr[30..&lt;45]</div><div style="font-family: Avenir; white-space: normal;" class="">mailingRecord.contacts.president.firstName = recordStr[45..&lt;53]</div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">// and so on..</div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">Ever worked for e.g. a bank with thousands of these files unchanged formats for years?</div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">Any alternative, convenient en simpler methods in Swift present?&nbsp;</div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div><div style="font-family: Avenir; white-space: normal;" class="">Kind Regards</div><div style="font-family: Avenir; white-space: normal;" class="">TedvG</div><div style="font-family: Avenir; white-space: normal;" class="">( example of the above Cobol record borrowed from here:&nbsp;</div><div class=""><font face="Avenir" class=""><span style="white-space: normal;" class="">&nbsp;<a href="http://www.3480-3590-data-conversion.com/article-reading-cobol-layouts-1.html" class="">http://www.3480-3590-data-conversion.com/article-reading-cobol-layouts-1.html</a>&nbsp; )&nbsp;</span></font></div><div style="font-family: Avenir; white-space: normal;" class=""><br class=""></div></div></pre><div class=""><br class=""></div><div class="">&nbsp; &nbsp;&nbsp;</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On 9 Feb 2017, at 16:48, Shawn Erickson &lt;<a href="mailto:shawnce@gmail.com" class="">shawnce@gmail.com</a>&gt; wrote:<br class=""><br class="">I also wonder what folks are actually doing that require indexing<br class="">into strings. I would love to see some real world examples of what<br class="">and why indexing into a string is needed. Who is the end consumer of<br class="">that string, etc.<br class=""><br class="">Do folks have so examples?<br class=""><br class="">-Shawn<br class=""><br class="">On Thu, Feb 9, 2017 at 6:56 AM Ted F.A. van Gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;&gt; wrote:<br class="">Hello Hooman<br class="">That invalidates my assumptions, thanks for evaluating<br class="">it's more complex than I thought.<br class="">Kind Regards<br class="">Ted<br class=""><br class=""><blockquote type="cite" class="">On 8 Feb 2017, at 00:07, Hooman Mehr &lt;<a href="mailto:hooman@mac.com" class="">hooman@mac.com</a> &lt;<a href="mailto:hooman@mac.com" class="">mailto:hooman@mac.com</a>&gt;&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Feb 7, 2017, at 12:19 PM, Ted F.A. van Gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;&gt; wrote:<br class=""><br class="">I now assume that:<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. -= a “plain” Unicode character (codepoint?) &nbsp;can result in one glyph.=-<br class=""></blockquote><br class="">What do you mean by “plain”? Characters in some Unicode scripts are<br class="">by no means “plain”. They can affect (and be affected by) the<br class="">characters around them, they can cause glyphs around them to<br class="">rearrange or combine (like ligatures) or their visual<br class="">representation (glyph) may float in the same space as an adjacent<br class="">glyph (and seem to be part of the “host” glyph), etc. So, the<br class="">general relationship of a character and its corresponding glyph (if<br class="">there is one) is complex and depends on context and surroundings<br class="">characters.<br class=""><br class=""><blockquote type="cite" class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. -= a &nbsp;grapheme cluster always results in just a single glyph, true? =- <br class=""></blockquote><br class="">False<br class=""><br class=""><blockquote type="cite" class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. The only thing that I can see on screen or print are glyphs (“carvings”,visual elements that stand on their own )<br class=""></blockquote><br class="">The visible effect might not be a visual shape. It may be for example, the way the surrounding shapes change or re-arrange.<br class=""><br class=""><blockquote type="cite" class=""> &nbsp;&nbsp;&nbsp;&nbsp;4. &nbsp;In this context, a glyph is a humanly recognisable visual form of a character,<br class=""></blockquote><br class="">Not in a straightforward one to one fashion, not even in Latin / Roman script.<br class=""><br class=""><blockquote type="cite" class=""> &nbsp;&nbsp;&nbsp;&nbsp;5. On this level (the glyph, what I can see as a user) it is not relevant and also not detectable<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with how many Unicode scalars (codepoints ?), grapheme, or even on what kind<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;of encoding the glyph was based upon.<br class=""></blockquote><br class="">False<br class=""><br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;<br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote>&lt;<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a>&gt;<br class=""><br class=""></blockquote><br class="">-- <br class="">-Dave<br class=""></div></div></blockquote></div><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></div></body></html>