Every time when I want ask here a question with a piece of code, I want to boil it down to possible minimum.
For example, a snippet from this question:
h = {'name' => 'sayuj',
'age' => 22,
'project' => {'project_name' => 'abc',
'duration' => 'prq'}}
d = h.dup # or d = h.clone
d['name'] = 'sayuj1'
d['project']['duration'] = 'xyz'
If I were to ask this question I would use this snippet:
original = {'a' => 1,'b' => {'c' => 1}}
dup = original.dup
dup['a'] = 100 # I changing dup, I don't touch original.
dup['b']['c'] = 100
p original['a'] # => 1 , didn't change
p original['b']['c'] # => 100 did change
Should I do this? On one hand I think that I should, because it's easier to understeand the code. But on the other hand I have to spend some time to boil it down to the minimum.
Should I edit questions in which code is not "minimized"?
Also, it helps avoid the XY problem, because it clarifies what actual problem is. I had several times when I was really sure about what the problem is and wanted to ask for help here, but just before I post the minimized code I realize that there is another problem.