Your two snippets are not equivalent as pointed out by @canton7.
That being said, this looks like a X-Y-Question and my advice would be to ask the actual question in Q&A Format.