What is the difference between ==~ and != in Groovy? In Groovy you also have to be aware that in addition to ==~, alias "Match operator", there is also =~, alias "Find Operator" and ~, alias "Pattern operator" All are explained here ==~ result type: Boolean boolean (there are no primitives in Groovy, all is not what it seems!) =~ result type: java util regex Matcher ~ result type: java util
What is the ?: operator used for in Groovy? - Stack Overflow The following code examples all produce the same results where x evaluates to true according to Groovy Truth These three code snippets mean the same thing If x is true according to groovy truth return x else return y x ?: y x ? x : y Standard ternary operator
What is the groovy lt; lt; operator mean in this context? In groovy, the bitwise operators can be overridden with the leftShift (<<) and rightShift (>>) methods defined on the class It's idiomatic groovy to use the leftShift method for append actions on strings, buffers, streams, arrays, etc and thats what you're seeing here
Groovy: whats the purpose of def in def x = 0? In unimportant scripts console input (like the groovy console) it's somewhat acceptable because the script's scope is limited I think the only reason groovy allows you to do this in scripts is to support DSLs the way Ruby does (A bad trade-off if you ask me, but some people love the DSLs)
Groovy == operator - Stack Overflow == in Groovy is roughly equivalent to equals(), however, you'll find it's different from Java when comparing different classes with the same value - if the class is Comparable Groovy also does type casting if possible If you check out the code, it looks like ultimately compareToWithEqualityCheck() is executed for ==
Groovy - How to compare the string? - Stack Overflow equals() does not behave the same in Groovy as it does in Java Example here-- scroll down to 'GString and String' Basically both items have to be of the same type of String class Since the String class is implicit in the assignment -- GString is a Groovy language construct and String is an inline definition, something like def foo = "foo"
Groovy: meaning of this inside a closure - Stack Overflow "this" in a block mean in Groovy always (be it a normal Java-like block or a Closure) the surrounding class (instance) "owner" is a property of the Closure and points to the embedding object, which is either a class (instance), and then then same as "this", or another Closure I would forget about the scope thing totally for this part
Groovy different results on using equals () and == on a GStringImpl In groovy a == b checks first for a compareTo method and uses a compareTo(b) == 0 if a compareTo method exists Otherwise it will use equals Since Strings and GStrings implement Comparable there is a compareTo method available