How to gets multi results using tuple in D?

zoujiaqing zoujiaqing at
Thu Dec 23 08:33:17 UTC 2021

C++ Code:
std::tuple<bool, int, int, std::string_view> DoIt()
     return {false, 0, 0, "Hello"};

auto [r1, r2, r3, r4] = DoIt();

if (r1 == false)


D Code:

Tuple!(bool, int, int, string) DoIt()
     return [false, 1, 1, "Hello"];

auto result = DoIt();

auto r1= result[0];
auto r2= result[1];
auto r3= result[2];
auto r3= result[3];

if (r1 == false)

D requires more lines of code.

More information about the Digitalmars-d-learn mailing list