Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
Select your favorite languages :
  • Or search :

Idiom #220 Create a tuple value

Create t consisting of 3 values having different types.

Explain if the elements of t are strongly typed or not.

let t = 1, 'a', "b"
#include <tuple>
auto t = std::make_tuple(2.5f, std::string("foo"), false);
#include <tuple>
std::tuple<float, std::string, bool> t(2.5f, "foo", false);
var t = (2.5f, "foo", true);
a, b, c := 2.5, "hello", make(chan int)
t := []interface{}{
	2.5,
	"hello",
	make(chan int),
}
t = (a, b, c)
let t = [2.5, "hello", -1];
record Tuple(int a, String b, boolean c) {}
var t = new Tuple(1, "hello", true);
val t = Triple(2.5, "foo", true)
type
  Tuple = record
    a: integer;
    b: string;
    c: boolean;
  end;
var
  t: Tuple;
begin
  t := Default(Tuple);
end.
use constant t => (1, 'two', 3.5);
t = (2.5, "hello", -1)
t = [2.5, "hello", -1]
let t = (2.5, "hello", -1);
Dim t = (2.5F, "foo", True)

New implementation...
< >
programming-idioms.org