On Sunday, 1 February 2026 at 03:38:34 UTC, Ali Çehreli wrote:
On 1/31/26 7:36 AM, kdevel wrote:

>> >        auto list = fail
>> >           ? typeof(someExpensiveOperation()).init
>> >           : someExpensiveOperation();

That works because in this simple code, which was to-me-clearly was an example to show the issue, someExpensiveOperation() does not take any parameters. That's why you can write that code in that "less complex" way.

Parameters to someExpensiveOperation do not make a difference:

   auto someExpensiveOperation(int dummy) {
      return [ "hello" ];
   }

   auto example_func (bool fail)
   {
      int n = 3;

      auto list = fail
         ? someExpensiveOperation(n).init
         : someExpensiveOperation(n);

      return list
         .filter!(a => a != "expensive")
         .map!(a => tuple!("value", "numLetters")(a, a.length));
   }

Reply via email to