Understanding of Link () function

I am a new user to Tulip and need your support to understand more about the link function. I have looked at the Technical Docs and also looked at the University Course but it is still not giving me clarity.
Can you provide some detailed examples on

  1. What does the Link() function do and how to use Link ().
  2. Does the Link () require the arguments to be of the same type?
    Thank you for your support. :pray:

Hi @Bhaskar, welcome! In my opinion the link() function is poorly named, but pretty straight forward once you understand that it’s not doing anything that you’d expect from the verb “link”.

The idea behind the link function is that some functions will not evaluate if one of the its values is null. I can explain it further like this:

Let’s say that we have any expression X + Y = Z. The value of X is 1 and y is null. In several programming languages, Tulip included, the expression 1 + null will not evaluate. Here’s where the link() function comes in. Link() essentially says, “I’m going to take a variable/tablerecord/etc as a value, and I’ll use that value if it’s not null. If the value is null, I’m going to take the next argument specified in the function.” So if using our example, we could write X + link(Y, 0) = Z and Z in this case will equal 1. We’re passing a 0 into the equation where there previously would have been a null value. You can add as many arguments as you’d like after the initial value, including other variables/table records. All arguments must be of the same type. If you’re familiar with coalesce() in SQL, it performs the same function.

Let me know if this helps!

1 Like

Is there a limit on the number of arguments that Link () function can accept? I hope not!

Thank you for taking the time to respond to my question, it is much appreciated. Your answer helps. Thanks a lot. I hope there is no limit to the number of questions, as I have many and would post more questions. :nerd_face: