How to check if an instance is of type String or GString in Groovy

后端 未结 3 1386
小蘑菇
小蘑菇 2021-01-03 17:56

I would like to learn what the robust way of checking, if a variable is of type string or gstring, is. I suppose it is different than in pure Java:

def var =         


        
3条回答
  •  北海茫月
    2021-01-03 18:47

    Instanceof tests should work:

    assert "fasd" instanceof String
    assert "${this}" instanceof GString
    

提交回复
热议问题