Java Reference
In-Depth Information
values2 << entry.value
}
Because a single dummy argument was used in the closure, I need to access its key and
value properties (equivalent to invoking the getKey and getValue methods, as usual)
to do the same operation as in the previous example.
Both mechanisms produce the same results:
assert keys1 == keys2
assert values1 == values2
Throughout this section I've used closures in examples without defining what they are.
That's the subject of the next section.
B.5. Closures
Like many developers, I started out in the procedural world. I started my career as a re-
search scientist, studying unsteady aerodynamics and acoustics. Most of that involved nu-
merically solving partial differential equations.
That meant that unless I wanted to write all my own libraries, I had to adopt Fortran as
my professional language of choice. [ 11 ] My first assignment in my first job was to take a
3000-line program my boss had written in Fortran IV [ 12 ] and add functionality to it. The
best part was that the original program had only two subroutines in it: one that was about
25 lines long, and the other 2975. Needless to say, I learned refactoring long before I knew
the actual term.
11 The fact that I seriously considered writing those libraries in a different language anyway was yet another sign I
was in the wrong profession.
12 Shudder. Holy arithmetic-if statements, Batman. The nightmares have stopped, but it took a while.
I rapidly learned what at the time were considered good development practices, meaning
thatIwrotestructuredprogramsthatusedexistinglibrariesasmuchaspossible.Itwasonly
in the mid-90s, when I first learned Java, that I was introduced to object-oriented program-
ming.
 
 
Search WWH ::




Custom Search