Skip to content

Instantly share code, notes, and snippets.

@gauravkukade
Created May 12, 2021 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gauravkukade/eafc65547cd3cd54877ca5d54eec8acc to your computer and use it in GitHub Desktop.
Save gauravkukade/eafc65547cd3cd54877ca5d54eec8acc to your computer and use it in GitHub Desktop.
If you want to check if an object implements a particular interface or extends a particular class (e.g. String, ArrayList, etc), you can use the `instanceof` keyword. check blogpost at https://coderolls.com/determine-a-datatype-in-groovy/
//If you want to check if an object implements a particular interface or extends a particular class (e.g. String, ArrayList, etc), you can use the `instanceof` keyword.
// check blogpost https://coderolls.com/determine-a-datatype-in-groovy/
def blogname = '''coderolls''';
println (blogname instanceof String) // true
println (blogname instanceof ArrayList) // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment