4 ms·
I agree that this trick is a bit hard to really understand if you first see it the first time and even harder to come up with, but I think it's quite readable e
by Xylakant 14y ago
I agree that this trick is a bit hard to really understand if you first see it the first time and even harder to come up with, but I think it's quite readable even if you don't understand what exactly is going on under the hood. So I'd have no qualms about using or allowing it in production code. It's safer than any proposed alternative, readable and does the job. Whether it's actually good architecture to depend on that knowledge is another discussion, but there's cases where it's required (see the inject example in this thread)
I'd never allow the instance_eval trick though, because that obfuscates the code for sake of saving a local variable.