Re: [SR-Users] Odd behavior comparing strings
On Thu, Oct 25, 2018 at 03:10:32PM +0100, Duarte Rocha wrote: > With "eq" it works as it should. Well, in principle, '==' ought to work as it should, too. It's still odd behaviour, I would agree. However, 'ne' and 'eq' are the operators explicitly designed for string comparisons. '==' and '!=' attempt to make appropriate type inferences based on the types of the operands, and as one can see, not necessarily consistently or correctly. -- Alex -- Alex Balashov | Principal | Evariste Systems LLC Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/ ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Odd behavior comparing strings
With "eq" it works as it should. Thanks :) ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Odd behavior comparing strings
Just out of curiosity, will this yield the same result? if($var(teste) eq 'Test') ? -- Sent from mobile. Apologies for brevity and errors. -Original Message- From: Duarte Rocha To: sr-users@lists.kamailio.org Sent: Thu, 25 Oct 2018 8:55 AM Subject: [SR-Users] Odd behavior comparing strings Greetings, I found an odd behaviour in Kamailio and i would like to know if it's intentional. I've made this snippet for showing : $var(teste) = $null; if($var(teste) == "Test") { xerr("TEST : If returned true"); } The "if" returns true if the $var is $null or 0. I'm using the "cmp_str()" now in order to avoid this issue. Best Regards, Duarte Rocha ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
[SR-Users] Odd behavior comparing strings
Greetings, I found an odd behaviour in Kamailio and i would like to know if it's intentional. I've made this snippet for showing : $var(teste) = $null; if($var(teste) == "Test") { xerr("TEST : If returned true"); } The "if" returns true if the $var is $null or 0. I'm using the "cmp_str()" now in order to avoid this issue. Best Regards, Duarte Rocha ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users