Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

aadishJ01
Copy link

No description provided.

Comment on lines +36 to +37
for (i in 1 until lines.size) {
var line = lines[i]
Copy link
Owner

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.

Comment on lines +38 to +39
line = line.replace("\\s+".toRegex(), " ")
var eachResponse = line.split(" ")
Copy link
Owner

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.

Comment on lines +51 to +53
var allResponseBranchWise = mutableListOf<List<Response>>()
groupByBranch.forEach { (k, v) ->
allResponseBranchWise.add(v)
Copy link
Owner

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.

Comment on lines +55 to +57
var threedList = allResponseBranchWise.chunked(3)
var req = mutableListOf<List<Response>>()
threedList.forEach { req.add(it.flatten()) }
Copy link
Owner

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.

Copy link
Owner

@ArpitShukIa ArpitShukIa left a 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 vars in the code which weren't really needed, they could have just been vals. Try to use val whenever you can and avoid using vars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants