In my attempt to create a linked list data structure I've declared two structs.
package main
import "fmt"
type listElement struct {
data int
next *listElement
}
type List struct {
first *listElement
last *listElement
len int
}
I want to create a method that returns an empty list. So far I've only been able to create the function
func new() *List {
return &List{}
}
This is the same result I've seen in multiple data structure repositories. Is it possible to create a method List.new()
that returns a new empty list?