Re: Using .require for struct types

2022-09-13 Thread Erdem via Digitalmars-d-learn
On Sunday, 11 September 2022 at 21:01:27 UTC, Salih Dincer wrote: On Saturday, 10 September 2022 at 16:33:03 UTC, Erdem Demir wrote: I wish I could use ref DListOfA returnVal = but we can't in D. Can you please suggest alternatives? I think you should try advanced update. Your

Re: Using .require for struct types

2022-09-13 Thread Erdem via Digitalmars-d-learn
On Saturday, 10 September 2022 at 18:39:55 UTC, Steven Schveighoffer wrote: On 9/10/22 12:33 PM, Erdem Demir wrote: Can you please suggest alternatives? Use a pointer. ```d DListOfA *returnVal = (...); returnVal.insert(a); ``` -Steve Actually that could be answer I am seeking for I will

Re: Using .require for struct types

2022-09-13 Thread Erdem via Digitalmars-d-learn
On Saturday, 10 September 2022 at 18:38:40 UTC, Ali Çehreli wrote: On 9/10/22 09:33, Erdem Demir wrote: > DListOfA returnVal = temp.require("a", DListOfA());--> I wish I > could use ref DListOfA here But keeping a reference to a temporary would not work because the life of that

Re: Using .require for struct types

2022-09-11 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 10 September 2022 at 16:33:03 UTC, Erdem Demir wrote: I wish I could use ref DListOfA returnVal = but we can't in D. Can you please suggest alternatives? I think you should try advanced update. Your flexibility and what you can do are limited by your dreams. A couple

Re: Using .require for struct types

2022-09-10 Thread Ali Çehreli via Digitalmars-d-learn
On 9/10/22 09:33, Erdem Demir wrote: > DListOfA returnVal = temp.require("a", DListOfA());--> I wish I > could use ref DListOfA here But keeping a reference to a temporary would not work because the life of that temporary ends by the end of that expression (practically, at the

Re: Using .require for struct types

2022-09-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/10/22 12:33 PM, Erdem Demir wrote: Can you please suggest alternatives? Use a pointer. ```d DListOfA *returnVal = (...); returnVal.insert(a); ``` -Steve