E4146#
Type is not supported by range pattern.
MoonBit only support range pattern for integer types. This error occurs when you try to use a type that is not an integer in a range pattern.
错误示例#
fn main {
let value = 1.0
match value {
_..<0.0 => println("negative") // Error: Type Double is not supported by range pattern.
_ => println("zero or positive")
}
}
建议#
For type that is not an integer but implements the Compare
trait, you can use
multiple if-else
expression to achieve the same effect.
fn main {
let value = 1.0
if value < 0.0 {
println("negative")
} else {
println("zero or positive")
}
}