Static member function returning immutable slice; compiler error: without this cannot be immutable

Ivo Maffei ivomaffei at gmail.com
Fri Jul 6 12:50:25 UTC 2018


Ok thanks to everyone for their help.

So I tried what you suggested and so the problem was bracketing.

For future reference, the above code can be fixed into this:

class Foo {
	private static Foo[] fooSlice; //private static slice

	static const(Foo[]) getFooList() { //static method returning a 
constant slice
		return fooSlice;
	}	
}




More information about the Digitalmars-d-learn mailing list