DEV Community

Discussion on: Demystifying the Long Arrow "Operator"

Collapse
 
worc profile image
worc

seems like an excellent way to frustrate the hell out of future maintainers. the formatting is weird and the value you declared for your index is never used. that's subtle and unexpected (two things you should never be striving for in code meant to be read by humans).

Collapse
 
beernutz profile image
beernutz

The value for the index is used, it is just used in a confusing way.
This whole article is just an example of what NOT to do.

Also, realize that the post decrement actually happens AFTER the comparison to zero, which might not be obvious to someone as well. As you say, don't do this with code that someone else might have to maintain.

Collapse
 
worc profile image
worc

i should clarify, the problem that stood out to me is the initial value of the index is never used in the body of the loop. that's what makes this thing so awful. the loop "works", but then you're left chasing an off-by-one error.

Collapse
 
somedood profile image
Basti Ortiz

Well, the point of this article isn't really to encourage you to use it, thus my recommendation against it towards the end of the article. It's just a fun way of reading code.

In the bright side, at least you now know what that weird long arrow means in some code bases if ever you encounter them.

Collapse
 
differentsmoke profile image
Pablo Barría Urenda

Come on, you don't discourage it nearly enough as you should if that was indeed your intention. This isn't something that "beginners shouldn't be doing", this is something that no one should be doing. Saying something isn't "for beginners" isn't condemnation, it's just motivation for aspiring ninjas. There's no upside to using this "operator": Long Arrow "operator" considered harmful.

Thread Thread
 
somedood profile image
Basti Ortiz

Don't worry. I'm pretty sure the comments section has discouraged its usage strongly enough. It's fascinating how passionate everyone is against the way of formatting such code.