Ad
  • Custom User Avatar

    Relax... note that I was disagreeing that anyone should be fired for writing code in this style.

    If it's causing that much offense, I'm deleting my comment.

  • Custom User Avatar

    In short: nobody cares about your opinion.

    In long: There are a dozen reasons why someone considers something best practice, and the classical UUN (aka "unreadable, unmaintainable and not for production") argument is the worst excuse to object to other's reasons why they think a solution is "best practice".

    And guess what? Most good golfers are also very good at learning, re-iterating, and writing clean, concise code with their language too because golfing actually takes effort. Now if you're really a "newcomer", I hope you don't hold your attitude like this for the rest of your life, because that means you aren't even learning, and it'd be the real terrible thing. I wouldn't even need to take a guess who is more capable.

  • Custom User Avatar

    Comment deleted because it might have upset someone

    TLDR: Agreed with Smudge that no one should be fired just because they code in this way, but expressed agreement with the sentiment that I don't find it great for readability. YMMV. It was just my opinion.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I don't disagree, but I hope you're not actually serious. Firing someone for an incomprehensible (albeit clever) one-liner seems particularly petty. If the developer truly doesn't understand the need for readable production code, there are plenty of ways to teach that lesson without taking extreme measures.

  • Default User Avatar

    You are totally correct, This is not best practice at all! If someone put this in production code I would have them fired unless they refectored it immediately.

  • Custom User Avatar

    I don't think you are. I would upvote this for cleverness but not for best practice. My initial feeling is that the main culprits damaging readability are the blocks passed to sort_by and inject. If you pulled those out into well named lambdas, they would better self-document what's going on inside those blocks.

    Experimented with this here: http://www.codewars.com/kata/reviews/51e056fe544cf36c41000102/groups/53840a80aa6fc153e50002e3
    Don't know that it's better.