Logo

Programming-Idioms

  • Ada
  • Clojure

Idiom #126 Multiple return values

Write a function foo that returns a string and a boolean value.

(defn foo
  []
  ["bar" true])

Make sure to invoke as a function call
so: _(foo)
#include <stdbool.h>
typedef struct {
    const char * const a;
    const bool b;
} RetStringBool;

RetStringBool foo() {
    return (RetStringBool) {.a = "Hello", .b = true};
}

New implementation...
< >
MLKo