Skip to content

Instance Method

isCastable(to:)

Returns true if concrete object can be exactly or losslessly cast to a second type
func isCastable(to type: LeafData.NaturalType) -> Bool

Discussion

  • EG: .nil -> .string(""), .int(1) -> .double(1.0), .bool(true) -> .string("true") are all one-way lossless conversions

  • This does not imply it’s not possible to coerce data - handle with coerce(to:) EG: .string("") -> .nil, .string("1") -> .bool(true)