Re:Go Proposal: first-class support for sorting slices
by leaveyou on Tuesday August 16, 2016 @01:13PM
(#12298919)
>interface{} is the new void*
There is an important difference between interface{} and void* which makes it a lot less reckless. AFAIK interface{} contains not only a pointer to data but also a reference to the type of the data. Therefore you can cast that data safely to the original type (or use "switch" on the type).
if origData, ok := data.(OriginalType); ok { /safe to use origData here*/ }
There is an important difference between interface{} and void* which makes it a lot less reckless. AFAIK interface{} contains not only a pointer to data but also a reference to the type of the data. Therefore you can cast that data safely to the original type (or use "switch" on the type). if origData, ok := data.(OriginalType); ok { /safe to use origData here*/ }