Home > other >  Small white ask a simple question..
Small white ask a simple question..

Time:11-17

Is in the open space of slice, I seem to be able to use two ways to do,
Could not find the go makedonwn, borrow C ha,

1. Strong commonality, the method of
 newList:=make ([] interface {}, 0) 

2. The specified directly used good slice structure,
 newList:=make ([] Liststruct, 0) 


I am a novice, don't know the use that is a best practice, if there is a difference between performance? Everyone in the work which is commonly used in defining way?

CodePudding user response:

Can be used in two ways, when you know what it needs in slice data, with the second, traversed can directly use the data, when you don't know what it needs in slice data with the first, traversed to interface {} type conversion, of course, the first one to put different types of data slice,
  • Related