Refactoring should also aim to make something either 1) more readable, 2) more performant (because of an actual need to make it more performant), or 3) more flexible to changes that have happened in the past. The code change above fails all 3. It's harder to understand what's happening thus making it less flexible to changes that may be needed in the future.
There is nothing special about a 1 liner (it's what I call "clever coding" always with the quotes, and it's a really bad practice). A computer can read 10 lines really really quickly, and it generally takes as long or longer for a human to decipher what the 1 liner actually does vs the 10 line equivalent.
I couldn't agree more about one-liners. Also using "tricks", little-known features and other "clever" stuff usually just makes the code harder to comprehend. IMHO the code example above doesn't really need refactoring anyway.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Refactoring should also aim to make something either 1) more readable, 2) more performant (because of an actual need to make it more performant), or 3) more flexible to changes that have happened in the past. The code change above fails all 3. It's harder to understand what's happening thus making it less flexible to changes that may be needed in the future.
There is nothing special about a 1 liner (it's what I call "clever coding" always with the quotes, and it's a really bad practice). A computer can read 10 lines really really quickly, and it generally takes as long or longer for a human to decipher what the 1 liner actually does vs the 10 line equivalent.
Great comment, some people still/will continue to think that "one line" is a huge performance optimization
I couldn't agree more about one-liners. Also using "tricks", little-known features and other "clever" stuff usually just makes the code harder to comprehend. IMHO the code example above doesn't really need refactoring anyway.