-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix typos in why_kotlin and add section on by lazy with hardware #26
base: main
Are you sure you want to change the base?
Conversation
Now uses by lazy as recommended by hex |
src/misc/why_kotlin/why_kotlin.md
Outdated
|
||
override fun init() { // or runOpMode() for LinearOpModes | ||
// To ensure that your hardware is initialized in the init stage, access it in some way to trigger the by lazy function | ||
arm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that in this example you already initialize it when you call arm.power
maybe make this more clear, that's about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just decided to remove the whole initialization example. This would slow down the first loop in some scenarios, but it would also ensure G405 compliance if the user isn't accessing in init. Kind of uncertain about this change though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just fix the two comments i put and we good
Should be fixed? |
I recently discovered the lateinit Kotlin keyword and found it really useful in FTC for accessing hardware. This PR adds it to the Cookbook page.