type Comparable interface{
CompareTo(c Comparable) int
}
type Int int
func (i Int)CompareTo(c Int) int{
return int(i-c)
}
func main(){
var i Int
i = 10
var c Comparable
c=i
fmt.Println(c)
}
Compiler complaint "Int doesn't implement Comparable(Wrong type for
CompareTo method)
And I modified to bellow
type Comparable interface{
CompareTo(c int) int
}
func (i Int)CompareTo(c int) int{
return int(i)-c
}
it's work.
I appreciate to anyone who explain this.
Best Regards
--
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/groups/opt_out.