<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">On 27 Jan 2017, at 11:27, TUNG CK via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:<br class=""><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div class="">Python, we have this<br class=""> for pixel in pixels:<br class=""> r, g, b, brightness = pixel<br class=""> .....<br class=""><br class="">I wonder how to do it in swift? is there a more swifty way to do something like this below?<br class=""> for pixel in pixels {<br class=""> var r = pixel[0]<br class=""> var g = pixel[1]<br class=""> var b = pixel[2]<br class=""> var brightness = pixel[3]<br class=""> .....<br class=""> }<br class=""></div></div></blockquote><br class=""></div><div>If Pixel is a tuple instead of an array, you can do:</div><div><div class=""><br class=""></div><div class="">var (r,g,b,brightness) = pixel</div><div class=""><br class=""></div><div class="">Alex</div><div class=""><br class=""></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a9a9a9" class=""> 1> </span><span style="font-variant-ligatures: no-common-ligatures" class="">let Pixel = (1,2,3,4)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Pixel: (Int, Int, Int, Int) = {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 0 = 1</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 1 = 2</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 2 = 3</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 3 = 4</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a9a9a9" class=""> 2> </span><span style="font-variant-ligatures: no-common-ligatures" class="">var (r,g,b,brightness) = Pixel</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">r: Int = 1</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">g: Int = 2</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">b: Int = 3</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">brightness: Int = 4</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(169, 169, 169); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 3> </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><br class=""></span></div></body></html>