lol I've seen some pretty insane one-liners, I think my criteria is as long as it doesn't look ugly. Once a one-liner isn't almost immediately obvious I always break it into multiple lines
That's more or less my criteria too.
Out of curiosity, have other people read the one-liners you thought were obvious, but had to take their time to understand them?
In my case, not many people see my code 😅 so I'm not sure if that's the same for everyone. In the end, the level of experience could make vary what is obvious and what no.
The only people I’ve found who find one liners hard to navigate are people who aren’t already familiar with comprehensions. Which is always a fun thing to teach.
I've kind of gotten a feel for what makes sense and what doesn't and this translates to readability for others as well. If the one-liner is longer than 79 characters that's usually a red flag and I always break my statements up as much as possible before introducing a complicated one liner. They usually end up reading more like pseudo code than anything too wild
I will admit I've gotten lazy though and written crazy one liners for throwaway programs or programs under time constraint and will return months later and have trouble reading my own code lol
lol I've seen some pretty insane one-liners, I think my criteria is as long as it doesn't look ugly. Once a one-liner isn't almost immediately obvious I always break it into multiple lines
That's more or less my criteria too.
Out of curiosity, have other people read the one-liners you thought were obvious, but had to take their time to understand them?
In my case, not many people see my code 😅 so I'm not sure if that's the same for everyone. In the end, the level of experience could make vary what is obvious and what no.
The only people I’ve found who find one liners hard to navigate are people who aren’t already familiar with comprehensions. Which is always a fun thing to teach.
I've kind of gotten a feel for what makes sense and what doesn't and this translates to readability for others as well. If the one-liner is longer than 79 characters that's usually a red flag and I always break my statements up as much as possible before introducing a complicated one liner. They usually end up reading more like pseudo code than anything too wild
I will admit I've gotten lazy though and written crazy one liners for throwaway programs or programs under time constraint and will return months later and have trouble reading my own code lol
That's one useful link!