![]() ![]() ![]() ![]() The code above might contain syntax errors. If your expressions become more complex, use a local function:įun associateNamePartsWithIndex(index: Int, name: String): Iterable> =ĭisclaimer: I don't know Kotlin. ![]() 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) 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. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |