Take the 2-minute tour ×

I've been asked to hunt down a bug and believe I have tracked it down to the following line of Groovy code:

return (engine.calipers.every { it.make != null });

This corresponds to an Engine class that contains an instance variable List<Caliper> calipers. I believe this code will return false if an Engine instance contains a single Caliper that has a null make field value. But not being a Groovy guy, I wanted a second set of eyes to confirm this for me. Am I on track, or way off-base? Thanks in advance!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

It will return true if every caliper item's make member is not null; false otherwise. But if any caliper item is null, it will throw a null pointer exception.

share|improve this answer
add comment

Your Answer

