18 lines
463 B
Text
18 lines
463 B
Text
/* gary chike 08/27/2023 */
|
|
|
|
class Main {
|
|
static Void main() {
|
|
inputs := ["152\n", "-3.141", "Foo123", "-0", "456bar", "1.0E10"]
|
|
|
|
inputs.each |Str input| { echo("$input.trim \tis " + (isNumeric(input) ? "numeric" : "not numeric"))}
|
|
|
|
static Bool isNumeric(Str input) {
|
|
try {
|
|
input.toFloat
|
|
return true
|
|
}
|
|
catch(Err e) {
|
|
return false
|
|
}
|
|
}
|
|
}
|