On 07/19/2016 02:30 PM, celavek wrote:
Hi,

I'm trying the following code:

class counter
{
public:

     final ulong[char] nucleotide_counts () const
     {
         return cached_counts;
     }

private:
     ulong[char] cached_counts;
}

void main()
{
}

I get the following error from the compiler:

    Error: cannot implicitly convert expression (this.cached_counts) of
type const(ulong[char]) to ulong[char]

I tried making the class variable constant, I tried the const in the
return type but I can't seem to get it right.

I would like to return a constant reference to the internal associative
array - much like in C++. How would I do that in D?

    final const(ulong[char]) nucleotide_counts () const
    {
        return cached_counts;
    }

Reply via email to