std.algorithms filter and string[]
Matt Peterson
ricochet1k at gmail.com
Wed Apr 11 07:05:06 PDT 2012
On Wednesday, 11 April 2012 at 13:55:45 UTC, Russel Winder wrote:
> I am having a dumb n00b moment, but I need to solve this 10
> mins ago ;-)
>
> immutable files = ( selector == 0 ) ? [ "." ] : filter ! ( (
> string x ) { return x.isFile ; } ) ( sliceOfStrings ) ;
>
> gives me the error:
>
> Error: incompatible types for ((["."]) ?
> (filter(sliceOfStrings))):
> 'string[]' and 'Result'
>
> which in one universe is fine, but in my universe is a problem
> as I
> cannot see a way of properly creating a Result instance based
> on the
> array literal.
>
> (I have a workaround, but I'd prefer to know the proper D idiom
> for
> this.
>
> Thanks.
Use the array(...) function from std.array to convert "Result" to
the string[].
More information about the Digitalmars-d
mailing list