Re: How can I use UFCS for a loop

2021-01-25 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 02:19:10 UTC, Tim wrote: On Tuesday, 26 January 2021 at 01:38:45 UTC, Q. Schroll wrote: On Tuesday, 26 January 2021 at 00:47:09 UTC, Tim wrote: Hi all, How can I change the following to a more D-like approach by using UFCS? double[3] result; Unless you have

Re: How can I use UFCS for a loop

2021-01-25 Thread Tim via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 01:38:45 UTC, Q. Schroll wrote: On Tuesday, 26 January 2021 at 00:47:09 UTC, Tim wrote: Hi all, How can I change the following to a more D-like approach by using UFCS? double[3] result; Unless you have a good reason, use a slice and not a static array:

Re: How can I use UFCS for a loop

2021-01-25 Thread Q. Schroll via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 00:47:09 UTC, Tim wrote: Hi all, How can I change the following to a more D-like approach by using UFCS? double[3] result; Unless you have a good reason, use a slice and not a static array: double[] result; The result of std.array.array will be a slice

Re: How can I use UFCS for a loop

2021-01-25 Thread Q. Schroll via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 00:47:09 UTC, Tim wrote: Hi all, How can I change the following to a more D-like approach by using UFCS? double[3] result; Json json = res.readJson; for(int i = 0; i < json.length; i++){ result[i] = json[i].to!double; } I'd prefer to do something like:

How can I use UFCS for a loop

2021-01-25 Thread Tim via Digitalmars-d-learn
Hi all, How can I change the following to a more D-like approach by using UFCS? double[3] result; Json json = res.readJson; for(int i = 0; i < json.length; i++){ result[i] = json[i].to!double; } I'd prefer to do something like: result = res.readJson[].map!(to!double);