Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-13 Thread Dennis via Digitalmars-d-learn
On Friday, 10 January 2025 at 16:57:10 UTC, An wrote: If the compiler flags this as an warning -> he probably notice the problem Lag of error/warn/hint for such case is not helping Happy coding I'm trying out making it an error: https://github.com/dlang/dmd/pull/20696

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-13 Thread Ali Çehreli via Digitalmars-d-learn
On 1/12/25 8:55 PM, H. S. Teoh wrote: > I wish there was some kind of syntactic sugar for assigning ctor > parameters to class members. Amen. Dart provides some help. It's under Generative Constructors here: https://dart.dev/language/constructors class Point { // Instance variables to hold

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-13 Thread user1234 via Digitalmars-d-learn
On Thursday, 9 January 2025 at 23:44:52 UTC, WhatMeWorry wrote: You misspelled the parameter name 'locaction', so your assignment in the constructor is a no-op: ``` this.location = this.location ``` Thanks. I was starting to question my sanity. That error is so classic that eventually a we

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-12 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 13, 2025 at 04:05:25AM +, Jim Balter via Digitalmars-d-learn wrote: > On Thursday, 9 January 2025 at 22:08:31 UTC, Dennis wrote: > > On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: > > > this(Location locaction, uint f) { > > > this.location = location;

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-12 Thread Jim Balter via Digitalmars-d-learn
On Thursday, 9 January 2025 at 22:08:31 UTC, Dennis wrote: On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: this(Location locaction, uint f) { this.location = location; this.f = f; } You misspelled the parameter name 'locaction', so your assignment in t

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-10 Thread An via Digitalmars-d-learn
On Thursday, 9 January 2025 at 22:08:31 UTC, Dennis wrote: On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: this(Location locaction, uint f) { this.location = location; this.f = f; } You misspelled the parameter name 'locaction', so your assignment in t

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-10 Thread WhatMeWorry via Digitalmars-d-learn
struct Node { uint multiplier; Location location; this(Location locaction, uint multiplier) { this.location = location * multiplier; this.multiplier = multiplier; } } I appreciate your example of the robustness of D, but if I was to make the same syntax mistake: this(Loca

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-09 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: produces: n = Node(Location(0, 0), 33) when I expected n = Node(Location(1, 2), 33) This is a simple typo (it shouldn't be 1 letter) but the code should be made smarter thanks to the capabilities of D. No more fear of writing lik

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-09 Thread WhatMeWorry via Digitalmars-d-learn
You misspelled the parameter name 'locaction', so your assignment in the constructor is a no-op: ``` this.location = this.location ``` Thanks. I was starting to question my sanity.

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-09 Thread Dennis via Digitalmars-d-learn
On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: this(Location locaction, uint f) { this.location = location; this.f = f; } You misspelled the parameter name 'locaction', so your assignment in the constructor is a no-op: ``` this.location = this.locati