Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 20:28:37 UTC, Seb wrote: On Friday, 7 December 2018 at 19:38:29 UTC, Arun Chandrasekaran wrote: On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: [...] Alternatively to the answers

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Seb via Digitalmars-d-learn
On Friday, 7 December 2018 at 19:38:29 UTC, Arun Chandrasekaran wrote: On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: [...] Alternatively to the answers above you can also use a custom lambda for canFind:

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/7/18 2:38 PM, Arun Chandrasekaran wrote: On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this expected? https://run.dlang.io/is/7OrZTA ```

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this expected? https://run.dlang.io/is/7OrZTA ```

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Seb via Digitalmars-d-learn
On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this expected? https://run.dlang.io/is/7OrZTA ``` #!/usr/bin/rdmd void main() { import

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 19:08:05 UTC, Arun Chandrasekaran wrote: On Friday, 7 December 2018 at 18:57:48 UTC, Dennis wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: Why is there a difference in the behavior? Your first assert expression is looking for a

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 18:57:48 UTC, Dennis wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: Why is there a difference in the behavior? Your first assert expression is looking for a string in a larger string, your second expression looks for hay which is

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/7/18 1:57 PM, Dennis wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: Why is there a difference in the behavior? Your first assert expression is looking for a string in a larger string, your second expression looks for hay which is not a string but a

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Dennis via Digitalmars-d-learn
On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: Why is there a difference in the behavior? Your first assert expression is looking for a string in a larger string, your second expression looks for hay which is not a string but a string[]. To flatten the array, use: