1

I've just been reading Marko Rodriguez's excellent blog post about different types of databases. Whilst reading I noticed some syntax...

// put data
db.put('marko');
db.put(31);
db.put(true);
// get data
Iterator results = db.get();
Iterator filteredResults = db.get{it.startsWith('ma')};

...which I presumed was a snippet of Java, but I've never seen a method invoked using curly braces like this before - db.get{it.startsWith('ma')}.

Any details/thoughts on this would be appreciated!

chattsm
  • 4,651
  • 5
  • 19
  • 20

1 Answers1

10

That looks like it's probably Groovy (using closures) rather than Java. Note that it also uses 'marko' which isn't valid Java. (Java uses single quotes for character literals, not string literals.)

That would also fit with the author's involvement in Gremlin, which is written in Groovy.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • I was wondering why marko wouldn't be valid, but at second glance see that it is the single quotes that are the problem. Yes, this looks like groovy. – Paul Croarkin May 24 '11 at 12:55
  • Ah yes, I should have spotted the string/character literal difference. I didn't realise Gremlin was written in Groovy either. Cheers guys! – chattsm May 24 '11 at 13:05