What am I missin with const?

estew estewh at gmail.com
Mon Jan 28 21:36:30 PST 2013


Hi,

Just started in D a week back after years of C/C++ head bashing 
and have to say language is fantastic.

I have a small misunderstanding regarding const...well ok, a 
fundamental misunderstanding by the looks of it:)

class A
{

ulong[] values;
...
const ulong[] getValue() const {
     return this.values;
}

}

But this fails to compile with the following message:
Error: cannot implicitly convert expression (this.values) of type 
const(ulong[]) to ulong[]

I just do not see it in the code. The function is const, so 
this.values is const, and I am just returning that as a const 
ulong[]. Am I not???


I don't get it? Any help explaining why this does not compile 
would be appreciated!

Thanks,
Stewart




More information about the Digitalmars-d mailing list