The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

SteveHigham (2) [Avatar] Offline
#1
I don't want to do the book down as I am enjoying it and learning Groovy. However the book clearly states that all assertions are tested prior to release and that doesn't seem to be the case.

I tried running the assertions in "Listing 3.6 Regular Expression GStrings" and a couple failed. Looking at them I wasn't surprised they failed. However I gave the authors the benefit of the doubt and put this down to a version mismatch.

However "Listing 3.8 - Working on each match of a pattern" contains a real howler. I can't believe this will succeed on any version of Groovy...

def myFairStringy = 'The rain in Spain stays mainly in the plain!'
// words that end with 'ain': bw*ainb
def wordEnding = /w*ain/
def rhyme = /b$wordEndingb/
...

When I run this the compiler complains (last line) that there is no variable "wordEndingb". Of course the intent is ${wordEnding}b but I would be very surprised if any Groovy compiler interprets this line in this way.

Any comments?

Steve
Domingo (7) [Avatar] Offline
#2
Re: These assertions have not been tested!
Seems that during publishing process backslashes of regular expression symbols went out. The code should look like:

def myFairStringy = 'The rain in Spain stays mainly in the plain!'

// words that end with 'ain': bw*ainb
def wordEnding = /w*ain/
def rhyme = /$wordEnding/

 stands for word boundary, w for word character.

It would be much better if authors have published the sources (even in MEAP - just part by time), something that I asked on this forum a few weeks ago.