18

I want to find out whether a variable is an array or not

  if (params.writtenLines == ???)

Much appreciated.

0

3 Answers 3

37

More importantly, why do you want to check whether it's an array? If you know the parameter might be a single string or a list, you can now use:

def lines = params.list("writtenLines")

That came with Grails 1.2.

Sign up to request clarification or add additional context in comments.

Comments

13

This functionality is already available in pure Java and can therefore be used in Groovy, too:

if (params.writtenLines.class.isArray())

1 Comment

Thanks dude, I found this as well if ( params.writtenLineID.getClass().isArray()) Keep up the good work cheers.
5

I realize this is a bit late, but what about this:

List.isCase(params.writtenLines)

Wouldn't it be a correct solution, too?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.