Chapel vs D

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 27 04:19:26 PST 2014


On 26/12/2014 18:38, bearophile wrote:
>> In C# i would use something like:
>>
>> int ThisNumber;
>> ThisNumber = Console.ReadLine();
>>
>> in D it looks worse with its "old" way of doing it:
>>
>> int thisNumber
>> readf("%s", &thisNumber);
>
> Do you want to use a "%d"?
>
> A more common way to do it in D is something like:
>
> auto inLines = readln.byLine;
> immutable thisNumber = inLines.front.to!int;
> inLines.popFront;

Or just:
int thisNumber = readln().to!int;


More information about the Digitalmars-d mailing list