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

Document classes #598

Merged
merged 9 commits into from
Jan 12, 2025
Merged

Document classes #598

merged 9 commits into from
Jan 12, 2025

Conversation

Akuli
Copy link
Owner

@Akuli Akuli commented Jan 11, 2025

Fixes #517

doc/classes.md Outdated
Comment on lines 168 to 187
If, for some reason, you want to pass the instance by value instead of a pointer,
you can specify the type of `self` like this:

```python
import "stdlib/io.jou"

class Point:
x: int
y: int

def increment_y(self: Point) -> None: # pass self by value
self.y++
printf("incremented to %d\n", self.y)

def main() -> int:
p = Point{x=12, y=34}
p.increment_y() # Output: incremented to 35
printf("still %d\n", p.y) # Output: still 34
return 0
```
Copy link
Contributor

@littlewhitecloud littlewhitecloud Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel a little bit confusing when reading this part about the using of self

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing! Is it better now?

Copy link
Contributor

@littlewhitecloud littlewhitecloud Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing! Is it better now?

Better now, but I perfer Point as default instead of Point* XD

@Akuli Akuli merged commit b599e1d into main Jan 12, 2025
26 checks passed
@Akuli Akuli deleted the classdoc branch January 12, 2025 01:32
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.

Document classes
2 participants