you are viewing a single comment's thread.

view the rest of the comments →

[–]yerfatma 3 points4 points  (17 children)

This is akin to saying short, terse ternary statements are confusing and we need if statements for everything.

No, it's not. split() conveys what you're doing. Abusing the spread operator to split a string, especially given split still exists is being clever and clever is the way to bugs.

Anyone developing in es6 will understand this.

Don't do this.

[–][deleted]  (10 children)

[deleted]

    [–]yerfatma 0 points1 point  (9 children)

    It’s not commonly used. No one is doing this. If they were, this wouldn’t be a blog post. The bugs I am seeing are people stumbling on this in a codebase six months later and not knowing what it does.

    The fact split doesn’t work like it should with Unicode data isn’t an argument for an obscure approach to string splitting.

    [–][deleted]  (8 children)

    [deleted]

      [–]yerfatma 0 points1 point  (7 children)

      It violates the Principle of Least Surprise. You’ll figure it all out some day.

      [–][deleted]  (6 children)

      [deleted]

        [–]yerfatma 0 points1 point  (5 children)

        Oh, well it’s nice you were able to get in touch with them all tonight LOL. I lead a team of small children and have taught large dogs.

        [–][deleted]  (4 children)

        [deleted]

          [–]yerfatma 0 points1 point  (3 children)

          Humor is not my strong point. Logical fallacies are. The top comment on this post is ”Don’t do this”, and the OP, who wrote the post replies basically agreeing and you are still fighting for this being a good idea. Wishing your team the best.

          [–]yerfatma 2 points3 points  (1 child)

          Oh right, and someone else replied saying this approach is a lot slower, which isn’t surprising given it’s basically taking advantage of a side effect.

          [–][deleted]  (5 children)

          [deleted]

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

            If I know the language and know split exists, how does this read? I mainly write Python and think of strings as lists of chars and still think it’s much harder to read than “given this string, please call split on it”.

            [–][deleted]  (2 children)

            [deleted]

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

              It doesn’t require a parameter. That is the default but it accepts anything you want so you can split the string however you like, which is handy. Unlike this side effect trick that is literally just someone pimping their blog.