Groovy Closure Example

A closure is an anonymous code block that can take arguments, return value, and also can be assigned to a variable. When it comes to Groovy, a closure can contain a variable scope defined outside of the closure expression. Groovy offers extended features to formal closure definition. By using this features, we can write our code more dynamically by applying closures to functions as parameter, caling anonymous code blocks inside functions, etc…. Let’s see closure in action with supporting examples.

Groovy Date Example

Date operations may be painful in most of the programming languages. You may spend most of your time to convert dates from one format to another one. In Groovy, date operations are very easy. Groovy has lots of functions extended from JDK Date API, this allows us to use date related operations in an easier way. Let’s have a look at how can we use Groovy date extension.

Groovy Array Example

In previous tutorials, we have mentioned about Groovy List and provided lots of examples. In this tutorial, I will show you how to use Groovy arrays. Even if array and list seems to be same, they have differences in common. For example, arrays have fixed size while lists have dynamic size that means you can add item as much as you can after initialization of the list.

Groovy Substring Example

Sometimes, the provided text may not be suitable for our needs. Because of this, we use string manipulation functions to convert it to desired format or extract specific part of it. You can hear this operation as substringoperation in software development world. In this tutorial, I will show you how to apply substring operations on a given string. In Groovy, you can use several ways to extract specific part of a given string. Let’s have a look at alternative ways to do some substring operations on strings

Groovy Console Example

In this tutorial, I will show you how to use Groovy Console to run your Groovy scripts and also give you some details about Groovy Console itself. Actually, there are several ways to run Groovy scripts. You can run it on your favourite IDE, you can run it from command line, or you can use Groovy Console to run your scripts. Groovy Console is a Swing GUI for perform several operations to your Groovy scripts. You may want to use Groovy Console to write and run Groovy scripts instead of IDE or command line. Let’s see features together.

Groovy List Example

List is generally used as stack in software development world in order to push items in it for future use and to be able to fetch back in a desired way. In this tutorial, I will show you how to use Groovy list like a senior developer. I assume, you have already set up Groovy on local machine and executed Hello World project

Groovy Map Example

In this tutorial, I will show you how to evaluate the power of Groovy maps. You will provided codes for each case and I assume that you have a little bit back ground about groovy. Let’s have a look at map concepts in groovy step by step together. 1. Map Declaration Maps are generally used for storing key-value pairs in programming