Page 1 of 1

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

Posted: 16 Dec 2022, 06:52
by V2User
@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.

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

Posted: 16 Dec 2022, 23:15
by lexikos
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.