Question about: ("1.1").to!int;
matheus
matheus at gmail.com
Fri Oct 23 13:45:54 UTC 2020
On Friday, 23 October 2020 at 08:09:13 UTC, Виталий Фадеев wrote:
> 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.
Of course 1.1 it's not an integer, but since (1.1).to!int works I
thought that ("1.1").to!int should work too.
Matheus.
More information about the Digitalmars-d-learn
mailing list