You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These data types can be treated just like any other class, and returned from functions.
publicTargetDatagetTargetInfo(){
vardata = newTargetData();
data.distance = //get data somehowdata.height = //get data somehowdata.relativeAngle = //get data somehowreturndata;
}
When combined with optionals, you can make very simple to use APIs.
Data classes can be very useful to provide more "atomic" data, without worry that one underlying part of your data type might change. This is often the case with sensors, which might subtly change while you're calculating data based on it.
They're also useful for correlating multiple data types between functions. The WPILib uses this in several places, such as Swerve's ModuleState (angle and distance),