Timeline for Comparing an array element to a value throws an error
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 25 at 13:44 | comment | added | Alexander |
Rather than iterating over indices and manually looking up elements like nums[index1] , you can use zip(nums, nums.indices) to iterate both the elements and indices together. example You can read more about that here: momchilov.ca/2020/06/30/array_iteration.html
|
|
Apr 25 at 13:41 | answer | added | Alexander | timeline score: 0 | |
Apr 25 at 0:29 | comment | added | HangarRash |
@ATL_DEV Semicolons are optional too. Very few Swift coders use parentheses on for or if (and others), nor semicolons. As a coder, you get to choose your style. Just be consistent about it. Always use them or never use them. Of course it's less typing if you choose not to use the optional syntax.
|
|
Apr 25 at 0:18 | review | Close votes | |||
25 mins ago | |||||
Apr 25 at 0:10 | comment | added | ATL_DEV | Swift should pick one or the other. The same should go for semicolons. There's some nice things about it, but the syntax is a bit ugly and unapple-like. | |
Apr 25 at 0:09 | comment | added | HangarRash | When posting an error with a line number, it’s helpful to point out which line of code is at that line. | |
Apr 25 at 0:06 | comment | added | HangarRash |
FYI - in Swift, just like a for statement, if statements don’t require parentheses either.
|
|
Apr 24 at 23:58 | comment | added | Stoic | Range operators in Swift | |
Apr 24 at 23:54 | vote | accept | ATL_DEV | ||
Apr 24 at 23:44 | comment | added | Dave Newton |
for index2 in index1+1...length but say for an 8-element array wouldn’t length be 7, so index1+1 can be 8 since ranges are inclusive and the first loop is 0-7?
|
|
Apr 24 at 23:37 | answer | added | Stoic | timeline score: 0 | |
Apr 24 at 23:20 | history | asked | ATL_DEV | CC BY-SA 4.0 |