Scala puzzlers pdf download
Must-Read Books. Subscriber Rating: [ 0 Ratings ]. Function values, especially anonymous functions, provide a convenient and concise way to create and pass around "portable" snippets of code. This is enhanced by allowing these snippets to reference values in scope when the function is defined, beyond just the immediate function parameters.
The following code creates "delayed accessors" for a set of values and invokes them later. What is the result of executing this code in the REPL? Since data, i, and j are no longer in scope when the functions are invoked, you may wonder whether the code compiles at all. Or you may wonder whether the functions all see the last value of data i and data j , and, as a result, both print:. As it happens, the code does compile, and the first statement prints the expected values , , The second statement never gets going, immediately throwing a runtime exception:.
The correct answer, therefore, is number 1. Before examining which differences between i and j result in the observed behavior, it is helpful to look at how Scala enables the function body to access these variables at all.
Beep Beep Reversing Reductio Ad Absurdum. It should be: an intentional language feature so no bugs not just weird because the reader doesn't know Scala "surprising" or "non-intuitive" to a reasonably skilled Scala developer Choose a puzzler from the left-hand list to get started!
Get the book! Last active Aug 29, Code Revisions 6. Embed What would you like to do? Embed Embed this gist in your website. Share Copy sharable link for this gist. The book provides both an authoritative reference for Scala and a systematic tutorial covering all the features in the language.
Once you are familiar with the basics of Scala you will appreciate having this source of invaluable examples and precise explanations of Scala on hand. The book is available from Artima. Award winning book - Jolt Productivity award for Technical Books. In Stock. Paper book usually ships within 24 hours. PDF eBook ready for immediate download.
Contents vii Foreword xiii Acknowledgments xiv Introduction xv 1. Hi There! Location, Location, Location 27 4. The Missing List 41 6. Arg Arrgh! Caught Up in Closures 50 8. Map Comprehension 55 9. Init You, Init Me 59
0コメント