-
Notifications
You must be signed in to change notification settings - Fork 556
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
Whitespace bugs? #1171
Comments
So the gotcha here is that "short hand return" is only valid if it's a single line.
x {
_x
//implicit return null
} what you're looking for is like this: because it's not a single line return shortcut, it must use the return keyword (otherwise it's just a "put the _x value on the stack and do nothing with it") x {
return _x
} |
the inverse is also invalid, e.g |
Thank you for clarification. |
This 'shorthand return' behavior is actually documented for functions but not (AFAICS) for methods. I'll do a PR to fix that. |
I only started using Wren yesterday, so I might have missed something in the docs. I was experimenting with OOP in Wren and I couldn't understand why all of the properties were always
null
! So I made a simple test case, and managed to figure out that it was the white-space that was causing the issue. I boiled it down to this code:When this code is run with Box1, it works as expected, it prints
2
. When this code is run with Box2, then it printsnull
. What exactly is happening here? Shouldn't Box2 work exactly the same as Box1?Box 1
Box 2
The text was updated successfully, but these errors were encountered: