Oliver Weichhold
Oliver Weichhold

Reputation: 10296

Identifying a map in groovy

While porting over a code fragment from python I've stumbled over a trivial problem:

if isinstance(v['content'], dict):

What would be the most elegant way to port this over to groovy?

Upvotes: 3

Views: 151

Answers (1)

DNS
DNS

Reputation: 38189

You can use instanceof (see map-specific example here), like this:

if (v['content'] instanceof java.util.map)

Upvotes: 5

Related Questions