My apologies if this question has been answered in the fourms before, but I'm fairly new to ARIS script and I'm trying to understand the behavior of the equals() method. It seems to behave differently than I expect, such as when comparing strings, it appears to ignore case. I was curious to know if there was a more full documentation on how the method works than what is in the help documentation or if someone who understands the quirks of the method can explain it to me. Thanks!
2 Replies
-
AFAIK it is Java's equals() method that is called in ARIS Script, so you should be able to get more info by looking into Java's documentation.
By the way, in my case, string comparison with equals() is case-sensitive, as it should be. This code, executed as an ARIS report, will return false (in a message box, so you don't need to use a debugger), for example:
Dialogs.MsgBox("foo".equals("Foo"))
This should call equals() of java.lang.String and this is case-sensitive. A non-case-sensitive comparison can be done with equalsIgnoreCase(). Not sure, why in your case equals() is not case-sensitive. Perhaps you are calling the method of another class?
-
Hello Michael,
which type of object are you talking about that has got an equals method? Strings? Javascript strings do not have an equals() method. If you created your strings as Java-Strings (java.lang.String) you get access to the Java equals() method of that class. In Javascript you compare strings usually with '==' or '==='. '==' does the typical Javascript type conversions, so ('1' == 4 - 3) would evaluate to true, while ('1' === 4 - 3) would be false.
ARIS currently works with an old Rhino 1.7.7 Javascript engine, which apparently also has disabled some of the more modern syntax of Javascript.