How do I create a type, record, and table?

It used to be easy in Classic:

type p  = [a = '', b = ''];
let rec = p[a = '', b = ''];
let tab = Empty(p);

Also, Table is gone, so I can’t use that method either.

So, this is my “hack” code:

type p    = {a: text, b: text};
let rec   = new lay {a: '', b: ''};
let tab   = rec & rec;
set tab   = empty(tab);

What is the best way to use a single type to create a record and a table from it?

Hi,

Those are very good points, and I believe that understanding the difference between “flow script definition typing”, and the more JSON-esque syntax when working with data is key in transferring your flow classic skills to flow connect.

Not sure if this exactly answers your question, but it is a great discussion. And I have been thinking of the best way to put this down in writing. So another example would be to just look at the different ways to return a single value, a record and a table:

And then the “definition typing”, as you correctly state, is also a little bit different as we, among other things now have null support (defined by a question-mark). And an asterix after the trailing curly bracket would give you a “table” (or a sequence actually, almost an array, but not indexed so more correctly called a sequence)

An example for the REST training, to point at the differences between “type-ing” and JSON:

Hello!

As you have noted, the Empty function in Connect no can no longer be used with a type name. (The reason for this change is that we wanted to avoid ambiguities between types and terms in the language.)

There are a couple of other ways:

type P = {a: text, b: text};

// Alternative 1: use the sequence syntax (square brackets)
let tab1: P* = [];

// Alternative 2: use the default keyword:
let tab2 = default(P*);