Hi, sir/mam
I have the follwing code in monkeyC
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.Math;
import Toybox.System;
//! Initial app settings view
class ToolKit {
public function foo() as Void
{
var tmp = Abs(-1); // this line will cause runtime error that the Abs function can not be found.
tmp = self.Abs(-1); // this line will cause runtime error that the Abs function can not be found.
tmp = ToolKit.Abs(-1);// This line will work.
}
public function Abs( x as Float or Number) as Float or Number {
if (x < 0) {
return -x;
} else {
return x;
}
}
}
It will generate a runtime error like: Abs is not found for the directly invoking or with self.Abs. Why?
Thank you for your time.