Groovy for Domain-specific Languages - Second Edition
Groovy Closures [ 98 ] then: "we expect that Groovy won't find a matching Closure" thrown MissingMethodException when: "we pass ...
Chapter 5 [ 99 ] Parameters and the doCall method You will note from the preceding example that we check for whether MethodMissi ...
Groovy Closures [ 100 ] A closure that accepts typed parameters will have a doCall method that accepts only the same specific t ...
Chapter 5 [ 101 ] Passing multiple parameters So far, our examples have all been using single parameters. To accept multiple par ...
Groovy Closures [ 102 ] In the preceding code, we implemented a simple closure, which accepts a single string parameter. We can ...
Chapter 5 [ 103 ] Curried parameters Curried parameters does not mean that we are including our parameters as ingredients in an ...
Groovy Closures [ 104 ] We can continue currying parameters until we run out of parameters (or curry powder). At this point, we ...
Chapter 5 [ 105 ] 2 } expect: closure(1) == 1 // return statement reached closure(-1) == 2 // ending statement evaluates to 2 If ...
Groovy Closures [ 106 ] } } given: "A class with a closure in a method" ClosureInClassMethodScope greeter = new ClosureInClassMe ...
Chapter 5 [ 107 ] myClazz.member = "second" def clos2 = myClazz.method("second") then: "new member, local and parameter values a ...
Groovy Closures [ 108 ] The this, owner, and delegate variables Groovy has three implicit variables in scope inside each closure ...
Chapter 5 [ 109 ] fg(7) == f(7*7*7) fg(13) == (2*(13*13*13)+4) and: gf(5) == g(f(5)) gf(7) == g(7*2+4) gf(13) == (13*2+4)*(13*2+ ...
Groovy Closures [ 110 ] factorial(6) == 1*2*3*4*5*6 when: "we use value that overflows the stack for recursion" factorial(10000) ...
Chapter 5 [ 111 ] trampolined.trampoline(n - 1, n * accumulator) }.trampoline() and: "we memoize() the trampolined closure" def ...
http://www.ebook3000.com ...
[ 113 ] Example DSL – GeeTwitter Before we dive any deeper into Groovy's more advanced features, let's take some time out to bui ...
Example DSL – GeeTwitter [ 114 ] With Twitter, you can tweet from the Web or from your mobile phone. If you register your mobile ...
Chapter 6 [ 115 ] Twitter APIs are all pure HTTP-based requests. Any method that just retrieves data such as a search operation ...
Example DSL – GeeTwitter [ 116 ] Running the curl command will display the resulting HTTP response from Twitter. This will inclu ...
Chapter 6 [ 117 ] Reading raw JSON tweets is obviously not user friendly. Fortunately, thanks to the vibrant developer community ...
«
2
3
4
5
6
7
8
9
10
11
»
Free download pdf