• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Another instanceof type question.  RSS feed

 
ranger
Sheriff
Posts: 17314
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I still need that other thread answered for one of my validations.

But for this other one here, It is different I am actually putting in String with instance of so (fieldValue instanceof String)

But what is odd, I have this if statement that is always returning as true, even when it should be false.



So that if is evaluating as true even when fieldValue is of type String. That part should be false.

Can't figure out what I am missing here.

Thanks

Mark
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works for me with Groovy 2.0.5

 
Mark Spritzler
ranger
Sheriff
Posts: 17314
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Gregg Bolinger wrote:This works for me with Groovy 2.0.5



So that wouldn't print W00t because it is of type String. Which is what I want.

To get around this I have to break the if statement into two separate ones.



And then it works the way I wanted and expected. Thanks for the replies.

Mark
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!