What is the best declaration type for a string like parameter?
Puming via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 28 17:58:36 PST 2016
On Thursday, 28 January 2016 at 15:03:38 UTC, sigod wrote:
> On Thursday, 28 January 2016 at 13:36:46 UTC, Puming wrote:
>> [...]
>
> `in char[]` is short for `scope const char[]` or `scope
> const(char[])`.
>
> See http://dlang.org/spec/function.html#parameters
>
> It depends on the situation. If possible I would use `in`
> modifier. If not then just `const`.
>
>> [...]
>
> Please, don't define such aliases. I'm sure a lot of developers
> will find it confusing. As I do.
>
> `const(char)[]` or `in char[]` is perfectly understandable as
> soon as you know what it means.
>
> Also, read this: http://dlang.org/spec/const3.html
Thanks. Now I get it.
Yes it is understandable now, but as a newbie the question "Why
my function that accepts a string does not work with lines in
file?" will pop.
More information about the Digitalmars-d-learn
mailing list