Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

j5155
Copy link
Contributor

@j5155 j5155 commented Oct 6, 2024

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.

@j5155
Copy link
Contributor Author

j5155 commented Oct 7, 2024

Now uses by lazy as recommended by hex

@j5155 j5155 changed the title Fix typos in why_kotlin and add section on lateinit with hardware Fix typos in why_kotlin and add section on by lazy with hardware Oct 8, 2024

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
Copy link
Owner

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

Copy link
Contributor Author

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.

Copy link
Owner

@dr-hextanium dr-hextanium left a 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

@j5155
Copy link
Contributor Author

j5155 commented Oct 16, 2024

Should be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants