string object won't compile
Adam D. Ruppe
destructionator at gmail.com
Mon Mar 5 23:42:59 UTC 2018
On Monday, 5 March 2018 at 23:34:50 UTC, askjfbd wrote:
> string.d
The problem is you named the file string.d and didn't give a
`module xxxxx;` statement in the code, so the compiler assumed
the module is named after the file.... and thus introduced a
local name `string` referring to the module, overriding the built
in one.
You can still refer to the built in one by saying `.string foo =
"bar";` - yes, the leading dot, which tells it to use the global
instead of local name.
Or by putting `module mytest.string;` at the top, so the module
has a two-part name (I recommend this in all cases anyway btw, it
is the best way to avoid conflicts as you import more modules).
Or just renaming the file from string.d to
almost_anything_else.d, which will also avoid the local name
override.
More information about the Digitalmars-d-learn
mailing list