CodeFaster

Share this post
Don't stomp variables
codefaster.substack.com

Don't stomp variables

Tyler Adams
Nov 10, 2021
1
2
Share this post
Don't stomp variables
codefaster.substack.com

Don’t do:

text = text.split(delimiter)

Instead do:

const a = text.split(delimiter)

That way at the end of the program you can add

console.log({a, text})

and see both the array and the original text

2
Share this post
Don't stomp variables
codefaster.substack.com
2 Comments

Create your profile

0 subscriptions will be displayed on your profile (edit)

Skip for now

Only paid subscribers can comment on this post

Already a paid subscriber? Sign in

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.

Andrew Judson
Writes Andrew’s Newsletter Nov 18, 2021

This makes sense in the case where the variable doesn't take up a lot of memory - stomping can make sense if you have a giant object (e.g. big pandas array) that you transform several times in the method

Expand full comment
ReplyCollapse
1 reply by Tyler Adams
1 more comments…
TopNewCommunity

No posts

Ready for more?

© 2022 Tyler Adams
Privacy ∙ Terms ∙ Collection notice
Publish on Substack Get the app
Substack is the home for great writing