5

From time to time I go back to my answers to see if I can improve something based on knowledge I gained in the meantime.

Some time ago I gave this answer and it was well received as you can see.
I referenced a different answer because it contains code ready to use and my answer basically points out how to use this code (literally what should the initial string value) to solve this particular problem.

These two questions are not duplicates because one is about integers and the other is about strings. Surprisingly enough with this particular requirement (Generate random integer with ALL digits from 1-9) it's easier and more efficient to start with string and convert it to integer after processing.

So, my question is: Should I include the code from other answer for a different question to make my answer complete? Or do we rather want to keep this site free of redundancy as much as possible?

Despite there is nothing more to add (except for the code) to my answer, it may look like a link-only answer until you read it.

5
  • I would suggest to add the code, but keep the link as attribution. That way if by some chance that answer is ever taken down, you still have the code.
    – Kendra
    Aug 21, 2014 at 15:55
  • I have no idea what that title says.
    – user1228
    Aug 21, 2014 at 16:59
  • N.B. I've added the code to the answer. Aug 21, 2014 at 17:32
  • @Will thank you. I have no idea how one word got swallown in the title. Aug 22, 2014 at 0:22
  • @RobertHarvey thank you. I'll keep it in mind. Aug 22, 2014 at 0:24

1 Answer 1

1

Should I include the code from other answer for a different question to make my answer complete?

Yes! Link only answers that point to any site, even SE sites, are at risk of deletion and should be flagged as Not an Answer. Answers should be self-containing and not need the person looking for help to go elsewhere to find the answer. As always, when including the code of someone else, appropriately cite the source of the code in your answer.

1
  • 1
    -1 for not including code/pics from the linked post May 12, 2015 at 0:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .