How to test if a variable obj is instance of a list regardless of the type that list is holding

I have tried

obj instanceof List
obj instanceof List<>

But I'm getting a compile error

  • 1
    Why do you even need to know? – Adrian Larson Mar 22 '17 at 20:23
  • @AdrianLarson working on an Apex framework so late days, I push the limits of the Apex language.... – benahm Mar 22 '17 at 20:24
  • Your answer would be a lot more interesting and might even garner upvotes if you make it more specific... – Adrian Larson Mar 22 '17 at 20:30
  • Sounds like it could be interesting. Do share – Eric Mar 22 '17 at 20:58
  • Be careful to avoid spurious edits. I've noticed you making trivial edits to a few of your posts recently. This post actively needs editing as mentioned above in the comments...perhaps try adding more substantive content. – Adrian Larson Mar 23 '17 at 13:31

Solved that

To test if a variable is a list regardless of the type of its elements

obj instanceof List<Object>
  • 3
    haha nice, seems like finding the solution was faster for you than typing the question. – Raul Mar 22 '17 at 20:21
  • Mark it as solved, benahm, so others can find it too! – Sebastian Kessel Mar 22 '17 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.