Question about: ("1.1").to!int;

Виталий Фадеев vital.fadeev at gmail.com
Fri Oct 23 08:09:13 UTC 2020


On Wednesday, 21 October 2020 at 22:50:27 UTC, matheus wrote:
> Hi,
>
> import std.stdio, std.conv;
> void main(string[ ] args) {
>     auto a = (1).to!int;     // this works
>     auto b = ("1").to!int;   // this works
>     auto c = (1.1).to!int;   // this works and c = 1
>     auto d = ("1.1").to!int; // Doesn't work
> }
>
> [...]

1.1 is not int.
"to" works fine.

As solution,... "1.1" should be splitted to lexems: "1", ".", 
"1". Then analyze and then converted to int.



More information about the Digitalmars-d-learn mailing list