initial commit
This commit is contained in:
20
source/Utils.mc
Normal file
20
source/Utils.mc
Normal file
@ -0,0 +1,20 @@
|
||||
import Toybox.Lang;
|
||||
|
||||
typedef Numeric as Number or Float or Long or Double;
|
||||
|
||||
// no types here, because this is generic, which are not supported by language
|
||||
function getOrElse(value, defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
function min(left as Numeric, right as Numeric) as Numeric {
|
||||
if (left < right) {
|
||||
return left;
|
||||
} else {
|
||||
return right;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user