be creative! ;-)

  import std.algorithm, std.stdio;

  void main () {
    string s = "he is at plane";
if (findAmong!((string a, string b) => b.canFind(a))([s], ["home", "office", "sea", "plane"]).length) {
      writeln("got it!");
    } else {
      writeln("alas...");
    }
  }

or:

  import std.algorithm, std.stdio;

  void main () {
    string s = "he is at home";
if (["home", "office", "sea", "plane"].canFind!((a, string b) => b.canFind(a))(s)) {
      writeln("got it!");
    } else {
      writeln("alas...");
    }
  }

The code is the best,and it's better than indexOfAny in C#:

import std.algorithm, std.stdio;
void main ()
{
    auto places = [ "home", "office", "sea","plane"];
    auto strWhere = "He is in the sea.";
    auto where = places.canFind!(a => strWhere.canFind(a));
    writeln("Result is  ",where);
}

Reply via email to