Calling readln() after readf

2021-04-24 Thread PinDPlugga via Digitalmars-d-learn
I didn't want to necropost, but I ran into the same behaviour as in this post: https://forum.dlang.org/post/yfybveovbknvvxmio...@forum.dlang.org and was just curious to understand it better. If I call readln() after having previously called readf(), it does not behave as expected: ```d import

ref struct member function

2021-05-13 Thread PinDPlugga via Digitalmars-d-learn
Hi I am working through Programming in D. In one exercise I have a helper function in a struct ```D struct Fraction { auto n = 0L; auto d = 1L; // ... other bits ... ref Fraction reduce() { import std.numeric : gcd; v = gcd(n, d); if (v > 1) { n /= v;

Re: ref struct member function

2021-05-14 Thread PinDPlugga via Digitalmars-d-learn
On Thursday, 13 May 2021 at 19:48:44 UTC, Ali Çehreli wrote: I was writing this example that shows a use case for the problem (marked with BUG below): ```D struct Fraction { auto n = 0L; auto d = 1L; // ... other bits ... ref Fraction reduce() { import std.numeric : gcd;

How is opEquals used in toHash

2021-05-18 Thread PinDPlugga via Digitalmars-d-learn
In the solution to one of the exercises in Programming in D the unittests fail with respect to the toHash implementation. Here is a link to the full solution provided: https://run.dlang.io/gist/99ddf791f86aaa9d333d032166aadcb9?args=-unittest%20-main and the link to the relevant section in the b