3

Please tell me what is the role of *= operator in below piece of code

@If(@UserRoles *= "[admin]" ; "" ; @Return(""));

It is formula language used in lotus notes databases.

NotesArt
  • 383
  • 9
  • 20

1 Answers1

3

That is a Permuted Equal.

 if a="this" or a="that" or a="other" then....

So this code sets to "" if is admin, otherwise it bails with a "".

Agree with @rhsatrhs, this is unclear and should be written using a normal =.

Here is a link to the Permutations operators official documentation.

Jouramie
  • 179
  • 5
  • 16
FlavorScape
  • 13,301
  • 12
  • 75
  • 117
  • Thanks for the answer. I am using it because got to do what has been assigned. – NotesArt Mar 27 '12 at 19:59
  • 3
    In this case, the permuted equal operator is completely unnecessary and should be removed for clarity. When comparing a list to a scalar, as is occurring here, the scalar is compared to each element of the list. In other words, you get the if a="this" or a="that" behavior with a regular "=" operator, so @UserRoles = "[admin]" is all you need -- even if the user does have multiple roles. The "*=" operator is only useful when comparing two lists, in which case every element of listA is compared with every element of listB. – Richard Schwartz Mar 28 '12 at 04:26
  • 4
    And no, *= is not like the ternary operator in other languages. Assigning an @If statement to a variable is the Notes formula equivalent of the ternary operator. I.e., the Notes formula x:= @If(condition,value1,value2); is the equivalent of C or Java's x = condition ? value1 : vaule2; – Richard Schwartz Mar 28 '12 at 04:33