August 04, 2022
On 8/4/22 00:57, pascal111 wrote:

> I don't see my post.

Some posts are blocked by the spam filter. (Apparently, your message did not have a sender name and cannot be passed because of that.)

Ali

August 04, 2022

On Wednesday, 3 August 2022 at 21:35:29 UTC, Ruby The Roobster wrote:

>

On Wednesday, 3 August 2022 at 19:11:51 UTC, pascal111 wrote:

>

[...]

No need for a code. See, there is a keyword called ref, that can be used both in function parameters and in foreach loops, and it is the equivalent of a pointer to the type specified, but it is automatically dereferenced. As arrays are themselves reference types, you don't need to change the parameter from Range range to ref Range range.

On the other hand, int in it of itself isn't a reference type, meaning that to modify the actual value, you need to change the foreach loop to be:

foreach(ref x; range)
    x = notfunny(x);

Proof: I tested it, and it works.

It works!

1 2
Next ›   Last »