[meaningless]Object in comparison (not to compare object)

Propose new features and changes
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

[meaningless]Object in comparison (not to compare object)

05 Nov 2015, 05:48

Document wrote:If either of the inputs is not a number, both are compared alphabetically
Currently, {}<0 (or o<0 which o is an object) is true and then, {}>0, o>0 are false. It seems object is convert to empty string, then ""<0 are compared alphabetically.
I think can't compare between object (or anything can't convert to number nor numerical string) and number.
I hope these comparison discriminant returns empty string.
3# wrote:Since condition of empty is treated as false, there still will be some conflict, even compare returns empty - need to use (a<0)=false to confirm false.
Maybe I over misused weak type, which simplify variable define and assign, I'd better check type first, if necessary.
Last edited by RobertL on 05 Nov 2015, 09:21, edited 2 times in total.
我为人人,人人为己?
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Object in comparison

05 Nov 2015, 06:27

Just write a simple function and use it instead of the = operator.
Recommends AHK Studio
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: Object in comparison

05 Nov 2015, 08:13

Since condition of empty is treated as false, there still will be some conflict, even compare returns empty - need to use (a<0)=false to confirm false.
Maybe I over misused weak type, which simplify variable define and assign, I'd better check type first, if necessary.
Thank you @nnnik
我为人人,人人为己?

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 59 guests