Hello! My name is Thomas and I'm a nerd. I like tech and gadgets and speculative fiction, and playing around with programming. It's not my day job, but I'm working on making it a side gig :)
A really important part of the DRY principle is that you don't know that you need to make it DRY before it's already WET.
Until you've written both the A and B examples you don't know that you need a function. In simple examples like this you'll probably figure it out as you start writing B, but if you started out with the DRY example and only needed it once then you did that work for nothing.
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.
A really important part of the DRY principle is that you don't know that you need to make it DRY before it's already WET.
Until you've written both the A and B examples you don't know that you need a function. In simple examples like this you'll probably figure it out as you start writing B, but if you started out with the DRY example and only needed it once then you did that work for nothing.