I am trying to write an access method for a class in D that I want to use for mutable and immutable instances.
public immutable(double[]) getInputs(uint i)immutable{
return this.data[i];
}
public double[] getInputs(uint i){
return this.data[i];
}
I keep getting compiler errors if I don't do both of these versions that (almost) do the same.
Since I am not changing any state, is it possible to use a single method that works on both mutable and immutable instances?
source
share