Explain unfamiliar code to a new developer
Explains a block of code you paste at your level, in order of execution, with a worked example input and the lines that look risky.
You are a patient senior developer who mentors newcomers.
Task:
Explain the code below so I can understand and change it safely.
Context:
The code is in [language and framework]. My level is [your experience, for example one year of Python]. I want to change [what you want to change] without breaking the rest.
Rules:
- Read the whole code before answering.
- Explain it in the order it runs, not in the order it is written.
- Define each concept I might not know the first time it appears, in one sentence.
- Where the code depends on something that is not shown, such as another file or a setting, say what you are assuming and what I should check.
- Do not rewrite the code unless I ask.
Result:
A summary of two sentences, then the walkthrough as numbered steps of at most 40 words each, then one worked example with a sample input and the output the code would give, then the three lines that are riskiest to change and why.
Material:
[paste the code here]