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

Java define return types #1277

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

Conversation

alexp141
Copy link

Added ability to define return types in Java more easily when creating a function. Previously, the return types would always default to void. Now, you can (optionally) decide to specify the return type of a function during creation. The previous way of defining functions still works too.

Example: saying "pub static String funky my function" will return
public static String myFunction()

This works for all of the code types defined in java.py

@alexp141
Copy link
Author

Just realized that this breaks every language that uses the code_functions tag that isn't Java. Will update if I come up with another solution.

@nriley nriley marked this pull request as draft October 28, 2023 15:29
@alexp141
Copy link
Author

alexp141 commented Oct 28, 2023

I have finished testing this and it looks like it works well.

Some final thoughts: There are two main ways I thought of doing this. The first way is the way that I did it in my first commit which involved changing all the code_* functions in functions.py to allow them to accept return values as arguments and the way that I did it in my last commit where the correct function is chosen based on whether the user dictates a return type or not. Both ways have pros and cons.

I also wanted to add that even though I only did these changes for Java, the same thing could be done for other languages as well.

Any feedback is appreciated!

@alexp141 alexp141 marked this pull request as ready for review October 28, 2023 19:13
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.

1 participant