On Wednesday, August 3, 2016 at 10:54:29 PM UTC+8, Axel Wagner wrote:
>
> Why is converting it in a loop "neither clean nor efficient"? It seems to
> be both to me: a) It's clean, as it's type-safe, so much less can go wrong
> and it's obvious what it does and b) it's efficient, becaue a func([]T)
> []interface{} would need to use reflection, just to also have the same loop
> (but a less efficient one, as every operation would need to reflect). So,
> writing a loop would, in fact, be *more* efficient and clean than a
> function.
>
If the functionality is provided by builltin package, the reflection is not
needed, just like the copy builtin function.
>
> On Wed, Aug 3, 2016 at 4:35 PM, T L <[email protected] <javascript:>>
> wrote:
>
>> Often, I need converting a []T to []interface{} to use the []interface as
>> a variable length parameter.
>> But converting a []T for []interface{} in a for loop is neither clean nor
>> efficient.
>>
>> So is there a function in standard lib to convert []T to a []interface{}?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.