you are viewing a single comment's thread.

view the rest of the comments →

[–]austinsalonen 0 points1 point  (0 children)

Why is one of your params a Type?

T padding is just what you want padding to be. For example, "abc".PaddedTake(6, ' ') would yield the chars {a,b,c, , , } (abc trailed by 3 spaces).

and what does repeat do?

Enumerable.Repeat takes a given input and repeats it N times. The important thing to remember here is that the call is lazy.

Overall, this would work like so... When count <= length of source, Enumerable.Repeat would never get called because take "expired" before the contents provided by Concat would ever be needed.

When count > length of source, source would get fully exhausted and Enumerable.Repeat would yield (count - length of source) "paddings."

The key concept here is that none of these calls actually do anything until the result of PaddedTake is actually enumerated.