C#5 desiderata

Adam Ruppe destructionator at gmail.com
Fri May 28 16:45:18 PDT 2010

On 5/28/10, bearophile <bearophileHUGS at lycos.com> wrote:
> in for arrays:
> if (x in (1, 2, 3)) {}

If the uniform function call syntax starts up, you could (maybe) do
something like this:

import std.algorithm;
import std.array;

bool among(T)(T v, T[] arr...) {
    return ! (arr.find(v).empty);

if( x . among ( 1, 2, 3 ) ) { }

This doesn't work right now because you can't do property syntax on
ints, but this might work in the near future.

It does work if you're looking for an array:

"hello" . among ( "world", "hello", "whatever" ); // compiles and runs
correctly right now

I picked "among" here since it does what it means and isn't a reserved
word like "in" right now. The name doesn't really matter though.

More information about the Digitalmars-d mailing list