// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.

// string.go
package kern

func IsBool(v any) (ok bool) {
	_, ok = v.(bool)
	return ok
}

func ToBool(v any) (b bool, ok bool) {
	ok = true
	switch x := v.(type) {
	case string:
		b = len(x) > 0
	case float64:
		b = x != 0.0
	case int64:
		b = x != 0
	case bool:
		b = x
	default:
		ok = false
	}
	return
}
