Re: Working with randomSample

2018-12-27 Thread Ali Çehreli via Digitalmars-d-learn
On 12/27/2018 06:06 PM, Murilo wrote: > Why is it that when I type "auto choice = randomSample(array);" and > later when I try to index choice as in choice[1] it gives an error message? It's because randomSample returns either an input range or a forward range depending both on the kind of

Working with randomSample

2018-12-27 Thread Murilo via Digitalmars-d-learn
Why is it that when I type "auto choice = randomSample(array);" and later when I try to index choice as in choice[1] it gives an error message?

Re: Qualified class opEquals()

2018-12-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 25, 2018 7:27:39 AM MST Per Nordlöw via Digitalmars-d- learn wrote: > On Tuesday, 25 December 2018 at 00:32:55 UTC, Paul Backus wrote: > > No, because equality comparison between classes lowers to > > `object.opEquals` [1], which takes both parameters as `Object`. > > This is

Re: mir.ndslice: assign a vector to a matrix row

2018-12-27 Thread David via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 18:59:25 UTC, 9il wrote: On Saturday, 15 December 2018 at 19:04:37 UTC, David wrote: Hi I am wondering if it is possible to assign a vector to a row of a matrix? main.d == import mir.ndslice; void main() { auto matrix =

Re: cas and interfaces

2018-12-27 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 27 December 2018 at 12:07:48 UTC, Rene Zwanenburg wrote: On Tuesday, 25 December 2018 at 22:07:07 UTC, Johannes Loher wrote: Thanks a lot for the info, that clarifies things a bit. But it still leaves the question, why it works correctly when inheriting from an abstract class

Re: Are the below statements equivalent?

2018-12-27 Thread Machine Code via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 18:03:44 UTC, Adam D. Ruppe wrote: On Wednesday, 26 December 2018 at 17:33:13 UTC, Machine Code wrote: Are the below statements equivalent? Yes, it is defined here: https://dlang.org/spec/statement.html#switch-statement (#2 in the list) Thanks!

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/27/18 10:53 AM, Adam D. Ruppe wrote: On Thursday, 27 December 2018 at 15:39:23 UTC, Steven Schveighoffer wrote: A template evaluating to a type void is how is(typeof(someTemplateDefinition)) works. Yeah, I know of that, but with __traits(isTemplate) now, I don't think there's any good

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 December 2018 at 15:39:23 UTC, Steven Schveighoffer wrote: A template evaluating to a type void is how is(typeof(someTemplateDefinition)) works. Yeah, I know of that, but with __traits(isTemplate) now, I don't think there's any good reason to use the old hack detection

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/27/18 9:45 AM, Adam D. Ruppe wrote: On Thursday, 27 December 2018 at 08:53:30 UTC, Johannes Loher wrote: If this behavior is indeed intentional, it should at least be covered in the spec. I know the template part is intentional (including the identifier thing, function names are

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 December 2018 at 08:53:30 UTC, Johannes Loher wrote: If this behavior is indeed intentional, it should at least be covered in the spec. I know the template part is intentional (including the identifier thing, function names are allowed to share names with global identifiers

Re: cas and interfaces

2018-12-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 25 December 2018 at 22:07:07 UTC, Johannes Loher wrote: Thanks a lot for the info, that clarifies things a bit. But it still leaves the question, why it works correctly when inheriting from an abstract class instead of implementing an interface... Any idea about why that? Unlike

Re: How do you get mouse movement info in GtkD?

2018-12-27 Thread Ron Tarrant via Digitalmars-d-learn
On Saturday, 30 January 2016 at 06:43:11 UTC, Enjoys Math wrote: There's also one that takes an Event param, but there's no obvious way to get the x/y info from that so I'll just use this lower level one which seems to work. I know this post is old, but a search I did the other day brought

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Johannes Loher via Digitalmars-d-learn
On Thursday, 27 December 2018 at 08:53:30 UTC, Johannes Loher wrote: On Thursday, 27 December 2018 at 04:27:03 UTC, Steven Schveighoffer wrote: [...] As a side note: During last DConf I talked to Walter and Andrei about the fact that `typeof(SomeTemplate) == void` and they agreed that it

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Johannes Loher via Digitalmars-d-learn
On Thursday, 27 December 2018 at 04:27:03 UTC, Steven Schveighoffer wrote: On 12/26/18 10:52 PM, Johannes Loher wrote: Hey all, I am a bit confused about the inferred types of function literals which do not name their parameters (something like `(int) {}`). The confusion arises from the fact