Question about the $ sign in arrays and strings

mipri mipri at minimaltype.com
Wed Feb 19 08:16:44 UTC 2020


On Wednesday, 19 February 2020 at 07:49:36 UTC, Namal wrote:
> oooh... I used
>
> str = std.readln();
>
> to get my string and there must have been some other sign, line 
> break or whitespace or something at the end  :(
>
> Now I understand it, thx

That makes sense. readln includes the newline:

$ echo hello | rdmd --eval 'readln.map!(std.uni.isWhite).writeln'
[false, false, false, false, false, true]

You can use std.string.chomp to drop it:

$ echo hello | rdmd --eval 
'readln.chomp.map!(std.uni.isWhite).writeln'
[false, false, false, false, false]



More information about the Digitalmars-d-learn mailing list