Wish to overload ?? when a object's property is undefined.

Propose new features and changes
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

Wish to overload ?? when a object's property is undefined.

16 Dec 2022, 06:52

@Lexicos Wish to overload ?? when a object's property is undefined.
See this code:

Code: Select all

try{
x:=a
}catch UnsetError{
x:=0
}
It can be almost equivalently replaced by x:=a??0 as the alternative.
Therefore, the other nearly the same code, should be replaced by x:={}.a??0 too.

Code: Select all

try{
x:={}.a
}catch UnsetError{
x:=0
}
Obviously, codes have been reduced and more uniform if ?? is extendsed.
It's worth mentioning that ?? can only ignore the exception which is near ??. For example, x:=myVar.a??0, in this situation, ?? can only handle a but can not handle myVar if myVar is also unset.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Wish to overload ?? when a object's property is undefined.

16 Dec 2022, 23:15

This is at least the second topic you have opened relating to extending the use of unset or related operators, and it puzzles me that you posted them in different subforums (v2 Development and Wish List). Please review the previous discussions in the topic Nothing., where I already covered the future use of ?? with properties. If you have anything further to add, please add it to an existing topic.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 58 guests