External reference with default value


#1

It would be nice if we could provide default values for custom references. Since typescript supports it, I hope it’s feasible.


#2

Hey @marks,

If you’re referring to creating functions with default parameters, ZapWorks Studio already supports this (as it’s a feature of our language of choice, TypeScript).

In the example below, exampleName will be assigned the value of "Seb Garcia". Even though Garcia wasn’t explicitly passed in as an argument during the function call, as it’s the default parameter it will be assigned Garcia as the default lastName value.

exampleName2 will return the value "Seb Smith" as Smith was explicitly passed in as the lastName argument.

function createName (firstName : string, lastName = "Garcia"){
    return firstName + " " + lastName;
}

let exampleName = createName ("Seb", undefined);
let exampleName2 = createName ("Seb", "Smith");


console.log(exampleName);
console.log(exampleName2);

Hope this helps. If you were referring to different functionality, or would like me to go over some parts do let me know.

All the best,
Seb


#3

No Seb I mean a custom reference


#4

Apologies @marks, seems I took your first link too literally :slight_smile:

Being able to add a default value to a custom reference is certainly helpful, and is something we’ll look into as we work on improving our references functionality.

Thanks again,
Seb