Index vs property

Certified Associate Developer

what is the main difference and what to use where

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    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

Reply
  • 0
    Certified Senior Developer

    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

Children
No Data