Using iteration / method chaining / etc on multi-dimensional arrays

Paul Backus snarwin at gmail.com
Thu Apr 12 21:17:30 UTC 2018


On Thursday, 12 April 2018 at 20:34:40 UTC, Chris Katko wrote:
>
> But each doesn't return anything, it mutates, right? I think 
> that's the problem I ran into with my attempt. With your code, 
> I get an error about void:
>
>   string []x = split(file.readln.idup, " ");
>   x.each((ref s) => s.each((ref n) => n.stripRight()));

You need to put an exclamation point after 'each' to pass the 
function as a template parameter:

     x.each!((ref s) => s.each!((ref n) => n.stripRight()));


More information about the Digitalmars-d-learn mailing list