Skip to content

A simpler way to create linked list #382

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

Merged
merged 1 commit into from
Aug 28, 2023
Merged

Conversation

tebeka
Copy link
Collaborator

@tebeka tebeka commented Aug 28, 2023

A simpler way to create a linked list by chaining it backwards.

}
last = &d
// Create a new node and link it backwards.
list = &data{p: list}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, since list is nil at the beginning this should work. I'm guessing you have tested this?

@ardan-bkennedy ardan-bkennedy merged commit 17dd748 into ardanlabs:master Aug 28, 2023
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