Skip to main content
New Participant
February 10, 2021
Question

Check if type is a list

  • February 10, 2021
  • 10 replies
  • 0 views

How do you check if variable is a list? Assuming that the variable is a local variable

    10 replies

    danny.verb
    Brainy
    February 10, 2021

    Can you add more details about your use case and what you're trying to do? A variable is just a reference to a value. You can use the contains() or wherecontains() functions to help find values within a list.

    New Participant
    February 10, 2021

    Hey Danny, I am trying to check if a certain variable is a list or not.

    For example:

    • local!list: {1, 2, 3}  - This is a list
    • local!list: 1 - This is not a list

    mikes0011
    Brainy
    February 10, 2021

    What are you hoping to do with this?  I assume Danny was asking for some more information about your overall use case, as we can provide more detailed guidance that way.

    The Expression Guru
    mathieud0001
    Brainy
    February 10, 2021

    I use the following:

    like(typename(runtimetypeof(local!value)), "List of*")

    stefanhelzle0001
    Brainy
    February 11, 2021

    This is dangerous as this string is localized to the users language.

    mathieud0001
    Brainy
    February 11, 2021

    That's what I thought as well but it doesn't seem to be the case. Nevertheless, I think your method is better.