I am very new to Kotlin, I was trying to migrate my java project to kotlin and I ran into a problem where I can't access implicit inherited members from my class.
In java I had a class called Robot.java which extends from TimedRobot.java and inside the TimedRobot.java there is a static member which is a double type
public class Robot extends TimedRobot {
}
TimedRobot.java from the library:
public class TimedRobot extends IterativeRobotBase {
public static final double DEFAULT_PERIOD = 0.02;
private double m_period = DEFAULT_PERIOD;
...
}
In the same package as the Robot.java I have a class called RobotConstants.java which holds some numbers. Even though there was no variable called DEFAULT_PERIOD in my Robot class I was still able to call it from outside like this:
public class RobotConstants {
public static final int PERIOD_IN_MS = (int)(Robot.DEFAULT_PERIOD * 1000);
...
}
However I am not able to do that in kotlin.
My robot class in kotlin:
class Robot : TimedRobot() {
}
And I am unable to get the default period in my constants object in kotlin, it gives me a compile time error. Here is what I am trying to do:
object RobotConstants {
const val PERIOD_Ms = (Robot.DEFAULT_PERIOD * 1000).toInt()
...
}
DEFAULT_PERIODonly viaTimedRobot- s1m0nw1