Chapter 2. Overture: Groovy basics

 

This chapter covers

  • What Groovy code looks like
  • Quickstart examples
  • Groovy’s dynamic nature

Do what you think is interesting, do something that you think is fun and worthwhile, because otherwise you won’t do it well anyway.

Brian Kernighan

This chapter follows the model of an overture in classical music, in which the initial movement introduces the audience to a musical topic. Classical composers weave euphonious patterns that are revisited, extended, varied, and combined later in the performance. In a way, overtures are the whole symphony en miniature.

In this chapter, we introduce many basic constructs of the Groovy language. First though, we cover two things you need to know about Groovy to get started: code appearance and assertions. Throughout the chapter, we provide examples to jumpstart you with the language, but only a few aspects of each example will be explained in detail—just enough to get you started. If you struggle with any of the examples, revisit them after having read the whole chapter.

An overture allows you to make yourself comfortable with the instruments, the sound, the volume, and the seating. So lean back, relax, and enjoy the Groovy symphony.

2.1. General code appearance

2.2. Probing the language with assertions

2.3. Groovy at a glance

2.4. Groovy’s place in the Java environment

2.5. Summary

sitemap