On 26 Apr 2017, at 18:13, Ole Begemann wrote:
> There have been requests for something like this on swift-evolution, e.g.
> here in the context of the discussion about a `reduce` variant that takes
> `inout` arguments:
> https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170123/0
Relatively straightforward to write this, which usually has meant "no" to
adding something to the standard library. (Not that I agree with that measure.)
Sent from my iPhone, please excuse brevity and errors
> On Apr 26, 2017, at 11:13 AM, Ole Begemann via swift-users
> wrote:
>
> On 26.04.20
On 26.04.2017 17:01, J.E. Schotsman via swift-users wrote:
On 26 Apr 2017, at 16:54, Rien wrote:
Agree, though the function should probably be named something like: withEach
instead of forEach.
Maybe worth a proposal on evolution?
Let’s wait until the people at the other side of the big lake
> On 26 Apr 2017, at 16:54, Rien wrote:
>
> Agree, though the function should probably be named something like: withEach
> instead of forEach.
> Maybe worth a proposal on evolution?
Let’s wait until the people at the other side of the big lake have had time to
react.
Jan E.
Agree, though the function should probably be named something like: withEach
instead of forEach.
Maybe worth a proposal on evolution?
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - A server fo
On 26 Apr 2017, at 16:27, Rien wrote:
> To edit the value in the array itself use:
>
> array[index].number += 1
That requires a for loop.
Functional programming lets you write for loops more succinctly.
Why can’t $0 not be used as a reference, like array[index] ?
I've checked, it’s not among t
Because you are (trying) to edit a copy.
To edit the value in the array itself use:
array[index].number += 1
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - A server for websites build in Swif
Simple question: why can’t I edit a variable array with a functional method?
For example:
struct TestStruct
{
var number = 0
}
var array = [TestStruct](repeatElement(TestStruct(), count: 2))
array.forEach { $0.number += 1 }
Jan E.