Reading this tutorial: http://ddili.org/ders/d.en/function_parameters.html
I cannot understand the difference between in
and const
: what is it?
dchar lastLetter(const dchar[] str) {
return str[$ - 1];
}
dchar lastLetter(in dchar[] str) {
return str[$ - 1];
}
It is nicely explained in the D Language Reference ( http://dlang.org/function.html#parameters ) section which describes parameter storage classes (off-topic items are omitted):
When they think about parameter storage class, D programmers should remember that D has value (structs, unions, static arrays and PODs) and reference (dynamic arrays, classes) types. The first group of types is always passed by value, unless you use the ref parameter storage class which is going to tell D compiler to explicitly pass by reference. Reference types will naturally be passed by reference, so ref is implicit in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With