-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completed the functions. #2
base: main
Are you sure you want to change the base?
Conversation
for (i in 1 until lines.size) { | ||
var line = lines[i] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have also used lines.forEach { line ->
instead.
line = line.replace("\\s+".toRegex(), " ") | ||
var eachResponse = line.split(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kotlin has an overload for split
function which directly accepts a Regex.
var allResponseBranchWise = mutableListOf<List<Response>>() | ||
groupByBranch.forEach { (k, v) -> | ||
allResponseBranchWise.add(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map
has a values
property which essentially gives a collection of all values. using that you could have avoided this loop.
var threedList = allResponseBranchWise.chunked(3) | ||
var req = mutableListOf<List<Response>>() | ||
threedList.forEach { req.add(it.flatten()) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also, you could have used the map
function and avoided this new MutableList
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. You code works perfectly. Just left a few comments on how you could have made it even more simple.
Also, I saw some var
s in the code which weren't really needed, they could have just been val
s. Try to use val
whenever you can and avoid using var
s
No description provided.