Ad
  • Default User Avatar

    Excellent post/question - I have been wondering the same for a while.

    IMO a one-liner lends itself well to this particular Kata. I had to admire how, in the top-rated solution, the author named the elements within each list of the data arguement. I myself used numbered indexes - a far less readable solution.

    As a casual/hobbyist coder i have managed just fine without the "one-liners". However, when searching for solutions online I frequently encounter them and have difficulty reading them. So for that reason and because they look cool, I challenged myself to learn them.

    During my research I learned that generators can use less memory, but may be slower to iterate through in certain instances but performance is rarely a priority for my scripts. Speed to acquire a working solution is usually the driving factor. Readability has become increasingly important as the population of scripts increases. Coming back to something I coded myself 6-12 months ago can take a while for me to digest.

    Unless the application requires extremes in either memory utilization, performance or readability one should strike a balance between getting the job done with your available skill-set and writing something you or others need to understand long after the initial release.

    I'm here to learn, so i see getting to grips with generators as an important step in the journey.

    If the line can be read out-loud and it makes sense to me, i'm good with it. Squeezing code into an abtract expression to save on digits and get up-voted is not why i came here - but we all have different goals.