# What is the difference, if any, in the following two slice declarations, and which one is more preferable?

Technology CommunityCategory: GolangWhat is the difference, if any, in the following two slice declarations, and which one is more preferable?
VietMX Staff asked 5 months ago
Problem
var a []int

and

a := []int{}

The first declaration does not allocate memory if the slice is not used, so this declaration method is preferred.