Skip to content

walkBack follow-up: Mention fold's potential in the examples#5227

Merged
wilzbach merged 1 commit intodlang:masterfrom
wilzbach:fold-walkBack
Mar 2, 2017
Merged

walkBack follow-up: Mention fold's potential in the examples#5227
wilzbach merged 1 commit intodlang:masterfrom
wilzbach:fold-walkBack

Conversation

@wilzbach
Copy link
Copy Markdown
Contributor

@wilzbach wilzbach commented Mar 2, 2017

Best outcome of this: a ddoc unittest of fold that prints the last line of a file.

Hmm we don't have many tests based on files and they usually are a bit clunky as one needs to write the file first.
So I simply added the "walkBack usage" to the existing unittests of fold.
However, I am happy to add a file example as well if you know a good spot ;-)

Copy link
Copy Markdown
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't waste time do you :)

// Can be used in a UFCS chain
assert(arr.map!(a => a + 1).fold!((a, b) => a + b) == 20);

// Return the last element of any range (walkBack)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

walkBack will not be clear without context, you may want to remove it

@wilzbach
Copy link
Copy Markdown
Contributor Author

wilzbach commented Mar 2, 2017

walkBack will not be clear without context, you may want to remove it

Ok fair enough -> removed.

You don't waste time do you :)

Such "improvements ideas" tend to get easily forgotten, so it's either now or never ;-)

@wilzbach
Copy link
Copy Markdown
Contributor Author

wilzbach commented Mar 2, 2017

Auto-merge toggled on

@andralex
Copy link
Copy Markdown
Member

andralex commented Mar 2, 2017

@wilzbach ask and ye shall receive: https://issues.dlang.org/show_bug.cgi?id=17238

@wilzbach wilzbach merged commit 7bd4c60 into dlang:master Mar 2, 2017
@wilzbach wilzbach deleted the fold-walkBack branch March 2, 2017 02:13
@wilzbach wilzbach restored the fold-walkBack branch March 2, 2017 02:17
@wilzbach wilzbach deleted the fold-walkBack branch March 2, 2017 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants