Can you read the next line while iterating over byLine?

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 2 21:25:15 PST 2017


Dne 2.2.2017 v 21:43 John Doe via Digitalmars-d-learn napsal(a):

> On Thursday, 2 February 2017 at 20:26:36 UTC, Daniel Kozak wrote:
>> Dne 2. 2. 2017 20:35 napsal uživatel "John Doe via 
>> Digitalmars-d-learn" < digitalmars-d-learn at puremagic.com>:
>>
>> On Thursday, 2 February 2017 at 18:58:46 UTC, Daniel Kozak wrote:
>>
>>> [...]
>>
>> Thanks readln is perfect. Since I am calling readln in different 
>> places and I always need to remove the newline character I have 
>> line=line[0..$-1] all over my code. Is there are better way?
>>
>>
>> you can use popBack on readln or trim but it is not more elegant. 
>> Maybe open enhancement on issues.dlang.org to phobos to add parameter 
>> for not keeping line end char
>>
>> unrelated second question: Why is there no split function with a 
>> maxsplit parameter?
>>
>>
>> what is maxsplit parameter, I have never use it or need it?
>
> Python's split function has an optional maxsplit parameter to specify 
> the maximum splits that should be done. So that "1,2,3,4,5".split(',', 
> 3) returns ['1', '2', '3', '4,5'].

How this is useful? How exactly do you use this (please show some 
example)? I belive if you show usefull usage it could be easily add to 
phobos. But to be honest I have never ever need such a thing :)



More information about the Digitalmars-d-learn mailing list