hi all, just wondering why type casting isn’t working
fails on 3, 4, NaN
type Kind int
const (
NaT Kind = iota + 1 // not a triangle
Equ // all sides equal
Iso // two sides equal
Sca // all sides different
)
func KindFromSides(a, b, c float64) Kind {
ma := map[int]interface{}{
1: a,
2: b,
3: c,
}
for i := 1; i <= 3; i++ {
if _, ok := ma[i].(string); ok {
return NaT
}
}
if a <= 0 || b <= 0 || c <= 0 {
return NaT
}
if (a+b+c)/3 == a {
if (a+b+c)/3 == b {
if (a+b+c)/3 == c {
return Equ
}
}
}
if a+b < c || b+c < a || c+a < b {
return NaT
}
if a == b || b == c || c == a {
return Iso
}
return Sca
}