You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String#each_line splits a string by line separator (LF or CRLF) and yields each individual line. Sometimes only populated lines are interesting, so you want to remove all empty ones. This can be accomplished by manual filtering. But that adds extra complexity to the call site. I think it would be useful to have a parameter remove_empty : Bool similar to String#split. #each_line is essentially a special case variant of #split.
The text was updated successfully, but these errors were encountered:
I suppose it depends on the ratio of empty lines, and whether a particular use case also involves ignoring lines consisting of only whitespace and the like.
Maybe it's not worth it. I just think it would fit well with the analogy of #split which performs the same kind of operation and has remove_empty, so it's easy to assume #each_line would have it as well.
String#each_line
splits a string by line separator (LF or CRLF) and yields each individual line. Sometimes only populated lines are interesting, so you want to remove all empty ones. This can be accomplished by manual filtering. But that adds extra complexity to the call site. I think it would be useful to have a parameterremove_empty : Bool
similar toString#split
.#each_line
is essentially a special case variant of#split
.The text was updated successfully, but these errors were encountered: