foreach and filter

Russel Winder russel at winder.org.uk
Wed Apr 11 09:08:14 PDT 2012


Doing something along the lines of:

	const a = array ( filter! ... ) ;
	foreach ( i ; a ) { ... }

works fine.  Question 1 though is why I can't use immutable here, why I
have to use const.  Question 2 is why I can't do:

	const a = filter! ... ;
	foreach ( i ; a ) { ... }

if I try this I get messages along the lines of:

./signatures_sequential.d(33): Error: function signatures_sequential.main.filter!(delegate @system bool(string item)
{
return isDir(cast(const(char[]))item);
}
).filter!(const(immutable(char)[])[]).filter.Result.empty () is not callable using argument types ()
./signatures_sequential.d(33): Error: function signatures_sequential.main.filter!(delegate @system bool(string item)
{
return isDir(cast(const(char[]))item);
}
).filter!(const(immutable(char)[])[]).filter.Result.popFront () is not callable using argument types ()
./signatures_sequential.d(33): Error: function signatures_sequential.main.filter!(delegate @system bool(string item)
{
return isDir(cast(const(char[]))item);
}
).filter!(const(immutable(char)[])[]).filter.Result.front () is not callable using argument types ()

which, it has to be said, isn't exactly informative to the user.

Thanks.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120411/384eca8a/attachment-0001.pgp>


More information about the Digitalmars-d mailing list