3 ms·
I wonder why Groovy decided to map "or" to the shell's "|". Wouldn't it have made more sense to map "or" to the shell's "||" and "pipe" to the shell's "|"?
by josephcsible 5y ago
I wonder why Groovy decided to map "or" to the shell's "|". Wouldn't it have made more sense to map "or" to the shell's "||" and "pipe" to the shell's "|"?
- tkot 5y agoI think this is just how operator overloading works in Groovy: https://groovy-lang.org/operators.html#Operator-Overloading https://groovy-lang.org/operators.html#Operator-Overloading "Or" is the name of the "|" operator. From the looks of it it's impossible to overload "||" in groovy. By the way the "|" operator and the "or" method both call "pipeTo" directly so a third way to write it would be: "ls".execute().pipeTo("grep -i old".execute()).waitForProcessOutput(System.out, System.out)