


It depends on what looks good for that particular code snippet. I use something different every time I write a piece of functional code. There is no hard and fast rule to the formatting. This is hard to marry with the use of lambda expressions, because their syntax kind of messes up the formatting. I prefer to put each chained method call on a separate line when writing functional code in Java. And extracting a method is a nice way to introduce a method name to summarize what's going on in an important intermediate step. Code takes up more lines, but less width, which is neither here nor there. Yes, this approach to method chain formatting may seem a bit extreme - but I find it very clean and consistent. what I guess I'm starting to settle on around formatting and indentation: Here's an example of my program running with the above input:Ġ.

each first name, last name, and email is a separate token, and the values are lists of indices of entries that contain that token. You're supposed to create an inverted index, basically a Map> where the key are tokens extracted from the entries, i.e.

Given a list of strings that represent entries in a phone book (one entry per line) While the first range will hold the list of multipliers corresponding to different rows, on the other hand, the second range will hold the result values.I've been working on one of the Kotlin projects at, Simple Search Engine, and the second to last stage has a bit of a challenging requirement to create an inverted index. Further, we’ll need two ranges in our loop. Let’s advance our understanding of looping with multiple variables by applying concepts of ranges and the zip operator to generate multiplication tables, where each row shows up in the format: factor x multiplier = resultĪs the factor will remain the same in all the rows, we’ll have to loop through two multiplier and result variables.
