3 ms·
Actually, I really enjoy using Groovy as a Java REPL, when having to use Java. Your code is run in a Script class Most java code is valid Groovy code and it ha
by putterson 12y ago
Actually, I really enjoy using Groovy as a Java REPL, when having to use Java. Your code is run in a Script class
Most java code is valid Groovy code and it has some nice dynamic features, syntax sugar and has closures. I am currently using it to hack together a small DSL to easily configure a transformation from XML -> CSV
Here's an example of a Groovy session (From my instance of IntelliJ IDEA through Tools -> Groovy Console)
> P = "Hello world!"
Hello world!
> sub = P.substring(5)
world!
> sub ==~ / wo.+/ ? println("World") : {}()
World
- vorg 12y ago> Most java code is valid Groovy code Up to Java 7 you could say "most" but why not "all"? Was it too difficult to test full compatibility? Why is the == slightly different between Java and Groovy, and the rest of the little differences which only confuse? And as for your example it doesn't look in the slightest like Java... P = "Hello world!" sub = P.substring(5) sub ==~ / wo.+/ ? println("World") : {}() Why wasn't Groovy updated so most java 8 code is also valid Groovy code? And why didn't you actually post some code to do something useful like "configure a transformation from XML -> CSV" instead of creating a HN login to post a meaningless syntax sample?