Ya compiler does give an error.
The piece of code is taken form an e-book.
probably some typo.