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

Should null-safe operators always return null or return primitives when requested? #198

Open
nicholashagen opened this issue Sep 29, 2012 · 1 comment
Labels
Milestone

Comments

@nicholashagen
Copy link

Currently, primitive properties on the right side of a lookup will return a default primitive value for a null-safe operation.

user = null as User;
user?.age // returns 0 if age is defined as int getAge()

This may be better off returning null and always an Object wrapper so that you can differentiate between invalid (null) and valid (potentially 0).

@jaxzin
Copy link
Member

jaxzin commented Sep 29, 2012

+1 for returning null and hiding the Java concept of primitives from Tea

On Sep 28, 2012, at 10:57 PM, Nicholas Hagen notifications@github.com
wrote:

Currently, primitive properties on the right side of a lookup will return a
default primitive value for a null-safe operation.

user = null as User;
user?.age // returns 0 if age is defined as int getAge()

This may be better off returning null and always an Object wrapper so that
you can differentiate between invalid (null) and valid (potentially 0).


Reply to this email directly or view it on
GitHubhttps://github.com//issues/198.

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

No branches or pull requests

2 participants