One thing I only recently learned about Groovy is that by implementing the
getAt method, you can destructure your Object via multiple assignment.
As an example, consider a class
Vector2D which represents a two-dimensional vector:
Last night, I saw a post on my twitter feed titled “Why Functional Programming in Java is Dangerous” where the author tries to implement the clojure code
in a functional style in Java, then concludes that “Functional idioms in Java are performance bugs waiting to bite you” after trying to load all of the Integers Java can handle into an ArrayList.
This Christmas, I received a Raspberry Pi from Santa, so thought I’d have a go at getting JavaFX running on it. Of course, due to my interest in all things Groovy, I decided to go straight for getting GroovyFX running. After a day or two of foozling around (and at least half a day getting distracted by the RASPBMC media centre), I succeeded so thought I would post the steps I took here so others can follow my path to GroovyFX happiness.
One of the things I love about how Groovy is built, is that quite a few of the examples in the Javadoc are automatically tested when you run
The beauty of this is that the examples you show the user in the documentation are guaranteed to work. No more out of date, flakey examples. And no more having to search the source with your fingers crossed there are Unit Tests, or searching the site for any sort of documentation.
Saw a tweet from Rob Fletcher about the 99 bottles of beer song written in LOLcode
And decided to see what it would look like with a groovy-stream.
This is what I ended up with:
If you’ve written a web-app you’ve undoubtedly hit the issue of people pasting text in from Microsoft Word. The problem here is that Word converts characters into other symbols to improve the typography, and this sometimes ends up with issues when you try and save the text into a database, or simply display it back to the user.
Today, I came across an old blog post by Ryan Senior with a cool example for describing family trees in The Godfather, and I wondered if it was possible to embed this code in a Groovy script so that we could pass a parameter into core.logic, and get the results back into Groovy.