what is the main difference and what to use where
Discussion posts and replies are publicly visible
Both are same , it clearly mentioned in Documentation that Property is alias of index
Normal difference is ,We go for Property function when we try to get the value of a property/Field in CDT or dictionary like property(CDT,"field",default value) it can be achieved through index too
And we use index to get the value from array like index(Array,3,null)
Both functions are almost work in same way
Both functions do the same thing
When accessing properties in a CDT (Complex Data Type) or a Dictionary, use the `property()` function. For example, `property(ri!myCdt, "userId", null())` attempts to retrieve the "userId" dot property
To look up an element in an array, use the `index()` function. For instance, `index(ri!myArray, 5, null())` tries to find the 5th item in the array. If the array does not contain that many elements, it will return null.
It's crucial to clarify the purpose of function calls, especially when reading code. This way, it's much easier to understand if the "index()" call is trying to find a property or an array index. This distinction can become quite messy, particularly when functions are nested
venkat Avuluri said:Normal difference is ,We go for Property function when we try to get the value of a property/Field in CDT or dictionary like property(CDT,"field",default value) it can be achieved through index too And we use index to get the value from array like index(Array,3,null)
Thank you, this is my normal soap box too.
For code readability especially, i (100% of the time) recommend property() be used for getting a "field" from a CDT, and index() be used for getting the index i.e. position within an array, when it's not 100% clear whether the array will have an entry at that index.