Re: How to use the Among method with a string array

2017-09-16 Thread Andrew Chapman via Digitalmars-d-learn
On Saturday, 16 September 2017 at 12:09:28 UTC, Adam D. Ruppe 
wrote:
On Saturday, 16 September 2017 at 11:18:45 UTC, Andrew Chapman 
wrote:

string[] fruit = ["apple", "pear", "strawberry"];

How do I use "among" to see if "apple" is present.  E.g.  I 
want to do this:


if ("apple".among(fruit))


among doesn't take an array, but rather a list of arguments:

"bar".among("foo", "bar", "baz")


For searching in an array, you can use canFind:

if(fruit.canFind("apple"))


Thanks Adam!


Re: How to use the Among method with a string array

2017-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 16 September 2017 at 11:18:45 UTC, Andrew Chapman 
wrote:

string[] fruit = ["apple", "pear", "strawberry"];

How do I use "among" to see if "apple" is present.  E.g.  I 
want to do this:


if ("apple".among(fruit))


among doesn't take an array, but rather a list of arguments:

"bar".among("foo", "bar", "baz")


For searching in an array, you can use canFind:

if(fruit.canFind("apple"))