On Tuesday, 5 April 2016 at 05:39:25 UTC, Timothee Cour wrote:
what's D's answer for C++11's uniform initialization [1] which allows DRY code?

Could we have this:
----
struct A{
  int a;
  int b;
}

A fun(A a, int b) {
  if(b==1) return i{0,1};
  else if(b==2) return i{2,3};
  else return fun(i{3,4}, 1);
}
----

A fun(A a, int b) {
  if(b==1) return [0,1];
  else if(b==2) return [a:2,b:3];
  else return fun([3,4], 1);
}

Reply via email to