hdkv
/
fwzookeeper
Archived
1
Fork 0
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues/pull-requests.
fwzookeeper/vendor/github.com/kirillDanshin/myutils/multival_to_singleval.go

40 lines
797 B
Go

package myutils
// First returns first argument of a function return
// use it like
// myutils.First(ab())
func First(args ...interface{}) interface{} {
if len(args) == 0 {
return nil
}
return args[0]
}
// Last returns first argument of a function return
// use it like
// myutils.Last(ab())
func Last(args ...interface{}) interface{} {
if len(args) == 0 {
return nil
}
return args[len(args)]
}
// Pick returns picked argument of a function return
// use it like
// myutils.Pick(1, ab())
func Pick(index int, args ...interface{}) interface{} {
if len(args) == 0 {
return nil
}
return args[index]
}
// Slice returns arguments of a function return as a slice
// use it like
// myutils.Slice(ab())[1]
func Slice(args ...interface{}) []interface{} {
return args
}