digitalmars.D - Hopefully not-too-obvious observation
- Jerry (9/9) Jul 17 2013 Hi folks,
- Simen Kjaeraas (6/13) Jul 18 2013 It's how I write my operator overloads unless the function should match
- Marco Leise (6/21) Jul 19 2013 I write it like that, too. It's more readable with the "in"
Hi folks, I was looking at writing a hash-like class with a specific operator and disliking the syntax of: T opBinary(string op)(U key) if (op == "in") {} When it occurred to me that it could be simply tightened up as: T opBinary(string op : "in")(U key) {} Any thoughts? Is this bad style? Thanks Jerry
Jul 17 2013
On 2013-07-18, 04:50, Jerry wrote:Hi folks, I was looking at writing a hash-like class with a specific operator and disliking the syntax of: T opBinary(string op)(U key) if (op == "in") {} When it occurred to me that it could be simply tightened up as: T opBinary(string op : "in")(U key) {} Any thoughts? Is this bad style?It's how I write my operator overloads unless the function should match several of them. So no, I think it's good style. But that's just, like, my opinion, man. -- Simen
Jul 18 2013
Am Wed, 17 Jul 2013 22:50:09 -0400 schrieb Jerry <jlquinn optonline.net>:Hi folks, I was looking at writing a hash-like class with a specific operator and disliking the syntax of: T opBinary(string op)(U key) if (op == "in") {} When it occurred to me that it could be simply tightened up as: T opBinary(string op : "in")(U key) {} Any thoughts? Is this bad style? Thanks JerryI write it like that, too. It's more readable with the "in" closer to the method name. -- Marco
Jul 19 2013