This is simplified code which I am using in my project.
```
struct NumberType
{
int num;
int opApply(int delegate(int) dg)
{
int result = dg(num);
return result;
}
}
struct Problem {
int value;
this(int val) {
auto myType = NumberType(18);
On Thursday, 3 July 2025 at 15:29:53 UTC, Nick Treleaven wrote:
On Monday, 30 June 2025 at 04:51:58 UTC, Rajesh wrote:
On Sunday, 29 June 2025 at 21:56:19 UTC, 0xEAB wrote:
On Sunday, 29 June 2025 at 13:06:38 UTC, Rajesh wrote:
Is there a restriction that I cannot call **return** from
foreach
On Monday, 30 June 2025 at 14:30:49 UTC, Manfred Nowak wrote:
On Sunday, 29 June 2025 at 13:06:38 UTC, Rajesh wrote:
[...]
```d
struct Problem {
this(int val) {
foreach (int number; myType)
return;
```
[...]
Is there a restriction [...]
Yes.
'this' is not allowed
On Monday, 30 June 2025 at 02:21:29 UTC, WraithGlade wrote:
On Sunday, 29 June 2025 at 13:06:38 UTC, Rajesh wrote:
This is simplified code which I am using in my project.
...
Welcome to the forum and good luck in your programming
endeavors Rajesh.
Honestly, it isn't clear what you are even
On Sunday, 29 June 2025 at 21:56:19 UTC, 0xEAB wrote:
On Sunday, 29 June 2025 at 13:06:38 UTC, Rajesh wrote:
Is there a restriction that I cannot call **return** from
foreach (opApply delegate) if it is executed at compile time?
To me this looks like a compiler bug where it runs into a wrong
On Monday, 30 June 2025 at 14:22:47 UTC, H. S. Teoh wrote:
On Mon, Jun 30, 2025 at 04:51:27AM +, Rajesh via
Digitalmars-d-learn wrote: [...]
```
Error: variable `__capture` cannot be read at compile time
onlineapp.d(27):called from here: `Problem(0).this(1)`
auto compile_time_var