(I have a while {} that I messed up....)
# suitescript
j
(I have a while {} that I messed up....)
s
avoid
while
and
for
🙂
j
😐
s
seriously - I almost never write
while
or
for
loops any more (to reduce my mistakes)
j
Dumb question....but how do you replicate the behaviour of a while/for loop another way?
s
I use functional libraries (e.g. immutablejs or lodash) or native functions (e.g. Array.map())
and when it comes to things like iterating over a sublist, I use NFT which is a thin layer that makes a sublist work in an array-like fashion and hence can be used directly with
lodash
and similar libs. For search results I do the same thing but make them compatible with libraries like
immutablejs
. The functions available on lodash and/or immutable better describe WHAT you're trying to do, and have established semantics. So not only do I get the benefit of not making mistakes writing loops, but my code is more undertandable to others that might read it down the road (because its using well established names from popular, well documented libraries rather than reinventing the wheel)
j
Gotcha. I'll look into that. I'm old school and so set in my ways....hah.
Thank you.
s
heh, I hear ya. I'm super old school but for me the only way to keep it all tolerable is to constantly try and find less painful ways to do things 🙂