3 ms·
I think if PHP is the only language you know this pattern probably feels extremely elegant. The JS guys also like to do stuff like this.
by maxxxxx 8y ago
I think if PHP is the only language you know this pattern probably feels extremely elegant. The JS guys also like to do stuff like this.
- CzechTech 8y ago> The JS guys also like to do stuff like this. Harsh, but fair.
- mattigames 8y agoJust wait until you meet dynamic dynamic variables, nothing more elegant than that... $x=0;$a='x';$b='a'; echo $$$b;
- duncan-donuts 8y agoHaven’t seen that one in the wild. Can that chain just keep going?!
- arkh 8y agoLazy coder here : foreach(['a' => closureA, 'b' => closureB, 'c' => closureC] as $name => $toApply) { $myObject->${convertNameToFieldName($name)} = $toApply($something); }
- Piskvorrr 8y agoToo clever by half - a textbook example. This is, in essence, write-only code.
- 52-6F-62 8y agoI write a lot of JS (read: TypeScript if I have any say in it) for work so I’m probably a JS guy. I hate stuff like that. It breaks more than it helps. It overcomplicates trying to dance your way through reasoning what is actually happening. It’s unreliable and I hate it. Carry on...