Imitating the “IN” Operator

I don’t think there is a very elegant solution. However, you could try: If Not IsError(Application.Match(x, Array(“Me”, “You”, “Dog”, “Boo”), False)) Then or you could write your own function: Function ISIN(x, StringSetElementsAsArray) ISIN = InStr(1, Join(StringSetElementsAsArray, Chr(0)), _ x, vbTextCompare) > 0 End Function Sub testIt() Dim x As String x = “Dog” MsgBox ISIN(x, … Read more

How to check if a value is equal or not equal to one of multiple values in Lua?

Your problem stems from a misunderstanding of the or operator that is common to people learning programming languages like this. Yes, your immediate problem can be solved by writing x ~= 0 and x ~= 1, but I’ll go into a little more detail about why your attempted solution doesn’t work. When you read x … Read more

Haskell infix function application precedence

The Haskell 98 Report has a section on Operator Applications that clears it up: An operator is either an operator symbol, such as + or $$, or is an ordinary identifier enclosed in grave accents (backquotes), such as `op`. For example, instead of writing the prefix application op x y, one can write the infix … Read more

‘is’ operator behaves differently when comparing strings with spaces

Warning: this answer is about the implementation details of a specific python interpreter. comparing strings with is==bad idea. Well, at least for cpython3.4/2.7.3, the answer is “no, it is not the whitespace”. Not only the whitespace: Two string literals will share memory if they are either alphanumeric or reside on the same block (file, function, … Read more

Use of double negation (!!) [duplicate]

It converts non-boolean types to boolean (dualvar(0,””) or 1). It is a shortcut way of doing this, instead of trying to cast it explicitly (which may take more characters). The ! operator negates the truthness of its argument. Hence, two of them are used. Many object types are “truthy”, and others are “falsey”. The only … Read more