d strings are the bane of my existance
Chris Katko
ckatko at gmail.com
Sun Dec 5 16:37:21 UTC 2021
On Sunday, 5 December 2021 at 16:32:16 UTC, rikki cattermole
wrote:
> The string is not the problem.
>
> ```d
> string ip_address = "192.168.1.1";
> auto x = new InternetAddress(ip_address, 8008);
> ```
>
> That works.
>
> A string in D is an alias for immutable(char)[]. This is
> defined in druntime (object.d).
>
> Immutable does cast to const implicitly, so a string argument
> to the constructor works fine as it has the same meaning.
>
> The port however, that needs to be a ubyte/ushort to pass in
> and not be a string like you had it.
Yes! Thank you! I just realized the latter part was broken when I
switched to using a uint for the addr. But I didn't know string
is an alias for immutable(char)[]! Thank you!
More information about the Digitalmars-d-learn
mailing list