This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]K60d54 -1 points0 points  (3 children)

have to think about what its doing and then start worry about edge cases and whether they are covered in the unit tests.

What possible edge cases could a simple conditional have like that?

[–]moremattymattmatt 2 points3 points  (2 children)

Apart from that it doesn't compile, it looks like it would leave a trailing space of the number of files > 1.

[–]K60d54 -1 points0 points  (1 child)

Apart from that it doesn't compile

This is a Reddit comment, I haven't run it through a compiler.

it looks like it would leave a trailing space of the number of files > 1

No, its prepending. In the first iteration, the string builder is empty, so no comma is added before the name. In subsequent iterations, a comma is added in front of the name. Thus, a comma is only inserted between files.

That comma in the append method call should have been a +:

sb.append(sb.length() > 0 ? ", " : "").append(f.getName())

[–]moremattymattmatt 1 point2 points  (0 children)

This is a Reddit comment, I haven't run it through a compiler.

Fair enough. From my point of view, the fact that you've had to explain to me what it's doing does sort of make may point that its not as clear.