Programming language cheat sheets for 20+ languages. Strings Mathematics [BitXXX e.g. BitAnd, XXXDiv e.g. TrueDiv] Operators and Symbols General (Control Flow/Debugging) Dates Objects [Range.New/Range.NewUntil] New Features Timelines Documentation Links Sections: Introduction By Role By Symbol Testing Operator Precedence Summary: Operators Across Multiple Languages Operators and Symbols Listed in: The C Programming Language (1978) The Universal Function Library Project: Details Inventing Operators Multi-Line Comments Note: UFL: Universal Function Library, a set of around 100-300 standard functions for all programming languages. Languages do not have to implement anything exactly to the UFL specification, it is a guide. See lower down for further details.
Note: most of these symbols are operators, but some are not, e.g. comment symbols. Operators are typically comprised of characters from what I call, the 'classic 32': !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ Start with ASCII chars 33-126 (94 chars), remove A-Za-z0-9 (62 chars), that gives 32 chars.
UFL: OpSpreadCall/OpSpreadReceive [spread operator (splat operator)][in a function call: 'spread' an array as multiple separate arguments][in a function definition: receive the trailing arguments (0 or more) as an array] AutoHotkey: */* C++: [none]/... C#: ../params Crystal: */* Excel: [none]/[none] Excel VBA: [none]/ParamArray Go: .../... Java: [none]/... JavaScript: .../... Kotlin: */vararg PHP: .../... Python: */* R: [none]/... Ruby: */* Rust: [none]/[none] Scala: */* SQL (MySQL): [none]/[none] SQL (PostgreSQL): [none]/VARIADIC SQL (SQLite): [none]/[none] Swift: [none]/... UFL: OpSpreadCallDemo [spread operator: for variadic function calls] AutoHotkey: * [e.g. MyFunc(oArray*)] C++: [none] C#: .. [e.g. MyFunc(..oArray)] [note: 2 dots (not 3)] [WARNING: .. doesn't work universally in function calls] Crystal: * [e.g. MyFunc(*oTuple)] [note: works on tuples but not arrays] [note: splat] Excel: [none] Excel VBA: [none] Go: ... [e.g. MyFunc(oArray...)] Java: [none] JavaScript: ... [e.g. MyFunc(...oArray)] [note: spread syntax] [also: MyFunc.apply(null, oArray)] [e.g. Array.prototype.push.apply(oArray, oArraySfx)] Kotlin: * [e.g. MyFunc(*oArray)] PHP: ... [e.g. MyFunc(...$oArray)] Python: * [e.g. MyFunc(*oArray)] [note: splat] R: [none] [can use: do.call(MyFunc, as.list(oVec))] Ruby: * [e.g. MyFunc(*oArray)] Rust: [none] Scala: * [e.g. MyFunc(oArray*)] SQL (MySQL): [none] SQL (PostgreSQL): [none] SQL (SQLite): [none] Swift: [none] UFL: OpSpreadReceiveDemo [spread operator: for variadic function definitions][see also: FuncDemoSum] AutoHotkey: * [e.g. MySum(oParams*)] C++: ... [note: fold expressions] [also: macros: ... and __VA_ARGS__] [also: va_list/va_start/va_arg/va_end (WARNING: this approach requires that the value of a param, e.g. the first param, indicate how many params were passed)] C#: params [e.g. public static int MySum(params int[] oParams)] Crystal: * [e.g. def mySum(*oParams)] [note: creates a tuple, not an array] Excel: [none] Excel VBA: ParamArray [e.g. Function MySum(ParamArray oParams())] Go: ... [e.g. func MySum(oParams ...int) int {] Java: ... [e.g. varargs syntax: static int MySum(int... oParams)] [WARNING: 'varargs' (with 's') is name, '...' is syntax] JavaScript: ... [e.g. function MySum(...oParams)] [also: oParams = Array.prototype.slice.call(arguments)] Kotlin: vararg [e.g. fun MySum(vararg oParams: Int) : Int] [WARNING: 'vararg' (no 's') is syntax and name] PHP: ... [e.g. function MySum(...$oParams)] Python: * [e.g. def MySum(*oParams):] R: ... [e.g. MySum = function(...)] [afterwards: oParams = list(...)] Ruby: * [e.g. MySum(*oParams)] Rust: [none] Scala: * [e.g. def MySum(oParams: Int*) : Int =] SQL (MySQL): [none] SQL (PostgreSQL): VARIADIC [e.g. CREATE FUNCTION MySum(VARIADIC oArray int[]) RETURNS int AS] SQL (SQLite): [none] Swift: ... [e.g. func MySum(_ oParams: Int...) -> Int] [note: ... is also used for closed ranges] UFL: OpTern [ternary operator: equivalent to 'if c, x, else, y']['c ? x : y' is preferable since it's clear/concise/common, else use alternative symbols like Raku ('c ?? x !! y')][note: 'if c, x, else, noop' can be achieved via: 'c && x'][a ternary function (e.g. 'Tern') is a lesser option since it can't do short-circuit Boolean evaluation (workaround: it could accept anonymous functions)][note: state if bool/parentheses needed, state if evaluates both branches][see also: IsTruthy/OpShortTern] AutoHotkey: c ? x : y C++: c ? x : y C#: c ? x : y [note: c must be a bool] Crystal: c ? x : y [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Excel: [none] [can use: =IF(c,x,y)] [note: c must be a bool or numeric] [WARNING: IF() evaluates both branches] Excel VBA: [none] [can use: IIf(c, x, y)] [note: c must be a bool or numeric] [WARNING: IIf() evaluates both branches] [note (IIf): immediate if (or inline if)] Go: [none] [can use (return int): vRet := map[bool]int{true: 1, false: 0}[vBool]] [can use (return string): vRet := map[bool]string{true: "true", false: "false"}[vBool]] [MAJOR WARNING: Go lacks any form of ternary operator, an if/else statement is a 5-liner, or a 6-liner if also declaring a variable] Java: c ? x : y [note: c must be a bool] JavaScript: c ? x : y Kotlin: if (c) x else y [WARNING: unusual operators] [note: c must be a bool] [note: can be used in expressions] [note: parentheses *are* needed] PHP: c ? x : y [note: can't chain ternary operator, unless use parentheses, e.g. a ? b : (c ? d : e)] Python: x if c else y [MAJOR WARNING: unusual operators, and operand order] [note: can be used in expressions] [note (a custom ternary function): Tern = lambda vBool, oFuncT, oFuncF : (oFuncT() if callable(oFuncT) else oFuncT) if vBool else (oFuncF() if callable(oFuncF) else oFuncF)] [e.g. Tern(vNum >= 0, lambda : print("is positive/zero"), lambda : print("is negative"))] [e.g. vSignBit = Tern(vNum >= 0, 0, 1)] [also: vRet = {True:1, False:0}[vBool]] R: if (c) x else y [also: ifelse(c, x, y)] [also: `if`(c, x, y)] [note: ifelse()/`if`() only evaluate one branch] Ruby: c ? x : y [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Rust: if c {x} else {y} [WARNING: unusual operators] [note: c must be a bool] [note: can be used in expressions] [note: curly braces are needed] Scala: if (c) x else y [WARNING: unusual operators] [note: c must be a bool] [note: can be used in expressions] [note: parentheses *are* needed] SQL (MySQL): [none] [can use: if(c, x, y)] [also: (CASE WHEN c THEN x ELSE y END)] [MAJOR WARNING: in MySQL, some non-blank strings are considered falsy (e.g. 'abc' is falsy, '123abc' is truthy), strings are cast to numeric, then numeric to 1 or 0] [note: if() only evaluates one branch] SQL (PostgreSQL): [none] [can use: (CASE WHEN c THEN x ELSE y END)] [note: c must be a bool] SQL (SQLite): [none] [can use: iif(c, x, y)] [also: if(c, x, y)] [also: (CASE WHEN c THEN x ELSE y END)] [MAJOR WARNING: in SQLite, some non-blank strings are considered falsy (e.g. 'abc' is falsy, '123abc' is truthy), strings are cast to numeric, then numeric to 1 or 0] [note: if()/iif() only evaluate one branch] Swift: c ? x : y [note: c must be a bool] UFL: OpShortTern [short-ternary operator][x ?: y][equivalent to x ? x : y][e.g. (x != 0) ? x : y][e.g. (x != "") ? x : y][if x is truthy, return x, else y][a 'falsy-coalescing operator': if x is non-falsy, return x, else y][note: can be chained to return the first truthy value, or last falsy value][see also: IsTruthy/Array.FindOrDefaultDemo/OpNullCoalescing/OpTern] AutoHotkey: || [note: AHK v2 onwards] [e.g. a || b || c] C++: [none] [can use: int oArray[] = {a, b, c}; auto oIter = std::find_if(std::begin(oArray), std::end(oArray), [](int v) {return v!=0;}); auto vValue = (oIter != std::end(oArray)) ? *oIter : 0;] [also: a?a : b?b : c] [requires (find_if): #include <algorithm>] C#: [none] [can use: Array.Find((int[])[a, b, c], v=>v!=0)] [WARNING: Find() returns the array's/list's default value if no match (e.g. 0 for ints, null for strings)] [also: (a!=0) ? a : (b!=0) ? b : c] Crystal: || [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [e.g. (but treats 0 as truthy): a || b || c] [can use: [a, b, c].find(0){|v|v!=0}] [also: (a!=0) ? a : (b!=0) ? b : c] Excel: [none] Excel VBA: [none] Go: [none] [can use: cmp.Or(a, b, c)] [requires: import "cmp"] Java: [none] [can use: Arrays.stream(new int[]{a, b, c}).filter(v->v!=0).findFirst().orElse(0)] [also: (a!=0) ? a : (b!=0) ? b : c] [requires (Arrays): import java.util.*] JavaScript: || [e.g. a || b || c] Kotlin: [none] [can use: arrayOf(a, b, c).find{it!=0} ?: 0] [also: if (a!=0) a else if (b!=0) b else c] PHP: ?: [e.g. $a ?: $b ?: $c] Python: or [e.g. a or b or c] R: [none] [can use: if (vVar) vVar else vDefault] [also: `if`(vVar, vVar, vDefault)] [note: an error occurs if NULL or a string is tested for truthiness] [also: Find(\(v) v!=0, c(a, b, c), nomatch=0)] Ruby: || [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [e.g. (but treats 0 as truthy): a || b || c] [can use: [a, b, c].find(->{0}){|v|v!=0}] [also: (a!=0) ? a : (b!=0) ? b : c] Rust: [none] [can use: [a, b, c].into_iter().find(|v|*v!=0).unwrap_or(0)] Scala: [none] [can use: Array(a, b, c).find(_!=0).getOrElse(0)] [also: if (a!=0) a else if (b!=0) b else c] SQL (MySQL): [none] [can use: if(a, a, b)] [also: (CASE WHEN a THEN a WHEN b THEN b ELSE c END)] SQL (PostgreSQL): [none] [can use: (CASE WHEN a!=0 THEN a WHEN b!=0 THEN b ELSE c END)] SQL (SQLite): [none] [can use: iif(a, a, b, b, c)] [also: if(a, a, b, b, c)] [also: (CASE WHEN a THEN a WHEN b THEN b ELSE c END)] Swift: [none] [can use: [a, b, c].first{$0 != 0} ?? 0] [also: (a != 0) ? a : (b != 0) ? b : c] UFL: OpNullCoalescing [or OpNullCoalesce][null-coalescing operator][x ?? y][equivalent to (x != null) ? x : y][if x is non-null, return x, else y][workaround: in some situations OpShortTern will work, e.g. (non-empty) objects are truthy, nulls are falsy][see also: Optional.UnwrapOrDefault/Array.Find/Array.GetOrDefault/OpShortTern] AutoHotkey: [none] C++: [none] C#: ?? Crystal: [none] [can use: [vVar,vDefault].find{|v|v!=nil}] [also: (vVar != nil) ? vVar : vDefault] [also (but with a confusing order): vVar.nil? ? vDefault : vVar] Excel: [none] [can use: =IFERROR(A1,MyDefault)] Excel VBA: [none] Go: [none] Java: [none] [can use: Optional.ofNullable(vVar).orElse(vDefault)] [also: oOpt.orElse(vDefault)] JavaScript: ?? [note: nullish-coalescing operator] [note: 'nullish': null or undefined] Kotlin: ?: [WARNING: in Kotlin, '?:' is a null-coalescing operator, not a short-ternary operator: e.g. '0 ?: 123' returns 0, since 0 is non-null] PHP: ?? Python: [none] [can use: next((v for v in [vVar] if v is not None), vDefault)] [also: vVar if (vVar is not None) else vDefault] R: [none] [can use (NA-coalescing): na.omit(c(vVar,vDefault))[1]] [also: if (is.null(vVar)) vVar else vDefault] [also: `if`(is.null(vVar), vVar, vDefault)] Ruby: [none] [can use: [vVar,vDefault].find{|v|v!=nil}] [also: (vVar != nil) ? vVar : vDefault] [also (but with a confusing order): vVar.nil? ? vDefault : vVar] Rust: [none] [can use (option object): oOpt.unwrap_or(vDefault)] [also: map_or/map_or_else/unwrap_or_else] Scala: [none] [can use (unwraps value): Option(vVar).getOrElse(vDefault)] [also (returns an option): Option(vVar).orElse(Option(vDefault))] SQL (MySQL): [none] [can use: coalesce(MyCol, MyDefault)] [note: coalesce() accepts 2 or more parameters, it returns the first non-null value, else null] [WARNING: ifnull() is a confusingly-named alias for the 2-param version of coalesce()] SQL (PostgreSQL): [none] [can use: coalesce(MyCol, MyDefault)] [note: coalesce() accepts 2 or more parameters, it returns the first non-null value, else null] SQL (SQLite): [none] [can use: coalesce(MyCol, MyDefault)] [note: coalesce() accepts 2 or more parameters, it returns the first non-null value, else null] [WARNING: ifnull() is a confusingly-named alias for the 2-param version of coalesce()] Swift: ?? [note: nil-coalescing operator] [note: Swift uses nils rather than nulls] UFL: SymSep [statement separator][for multiple statements on 1 line] AutoHotkey: , C++: ; [note: statements must end with ;] C#: ; [note: statements must end with ;] Crystal: ; Excel: [none] Excel VBA: : [note: colon (not semicolon)] Go: ; [note: the Go Playground auto-formats these away (replacing multi-statement one-liners with multiple lines)] Java: ; [note: statements must end with ;] JavaScript: ; Kotlin: ; PHP: ; [note: statements must end with ;] Python: ; R: ; Ruby: ; Rust: ; [note: statements must end with ; (except the last)] Scala: ; SQL (MySQL): ; [note: statements must end with ; (except the last)] SQL (PostgreSQL): ; [note: statements must end with ; (except the last)] SQL (SQLite): ; [note: statements must end with ; (except the last)] Swift: ; UFL: SymEnd [statement terminator][whether lines must end with a char/symbol (e.g. semicolon)] AutoHotkey: [none] C++: ; C#: ; Crystal: [none] Excel: [none] Excel VBA: [none] Go: [none] Java: ; JavaScript: [none] [note: it is common to end lines with ;] Kotlin: [none] PHP: ; Python: [none] R: [none] Ruby: [none] Rust: ; [note: the last statement does not require a trailing semicolon] Scala: [none] SQL (MySQL): ; [note: the last statement does not require a trailing semicolon] SQL (PostgreSQL): ; [note: the last statement does not require a trailing semicolon] SQL (SQLite): ; [note: the last statement does not require a trailing semicolon] Swift: [none] UFL: SymStringLiteral [or SymStrLiteral][characters for assigning string literals][see also: SymInterpolateVarDemo/Format/SymCharApos/JsonArrayDemo/JsonObjectDemo] AutoHotkey: " [also (AHK v2 onwards): '] C++: " [note: ' is used for chars] C#: " [note: ' is used for chars] Crystal: " [note: ' is used for chars] Excel: " Excel VBA: " [WARNING: ' is used for comments] Go: " [note: ' is used for chars] Java: " [note: ' is used for chars] JavaScript: " [also: '] Kotlin: " [note: ' is used for chars] PHP: " [also: '] Python: " [also: '] R: " [also: '] Ruby: " [also: '] Rust: " [note: ' is used for chars] Scala: " [note: ' is used for chars] SQL (MySQL): ' [also: "] [WARNING: ' is used for strings] [note: ` is used for identifiers (e.g. column names)] [note: the same rules apply to stored functions] SQL (PostgreSQL): ' [WARNING: ' is used for strings] [WARNING: " is used for identifiers (e.g. column names)] [note: the same rules apply to stored functions] SQL (SQLite): ' [WARNING: ' is used for strings] [WARNING: " is used for identifiers (e.g. column names)] Swift: " UFL: SymCharLiteral [characters for assigning character literals][see also: SymCharApos] AutoHotkey: [none] C++: ' [note: ' is also a digit separator] C#: ' Crystal: ' Excel: [none] Excel VBA: [none] [WARNING: ' is used for comments] Go: ' Java: ' JavaScript: [none] Kotlin: ' PHP: [none] Python: [none] R: [none] Ruby: [none] Rust: ' Scala: ' SQL (MySQL): [none] SQL (PostgreSQL): [none] SQL (SQLite): [none] Swift: [none] UFL: SymEscape [string escape character][individual characters by frequency: nrt\'" abfv0 es$;?][see also: IntToStrCharEscapeDemo/StringNewDemoAscii/StrMultiLineDemo] AutoHotkey: ` [`a `b `f `n `r `s `t `v `` `' `" `;] [note: `; only required if ; is before space/tab] [note: AHK v1 used dual quoting for "] [also: A_Space A_Tab] C++: \ [\a \b \f \n \r \t \v \' \" \\ \?] [also (with further chars): \0 \N \u \U \x] [also: \c] [WARNING: \x stops at the first non-hex digit (workaround: use string literal concatenation, to mark the end of the sequence)] C#: \ [\a \b \e \f \n \r \t \v \' \" \\ \0] [also (with further chars): \u \U \x] [WARNING: \x can handle 1-4 hex digits, but it is safer to always use 4 (to avoid later chars being accidentally interpreted as part of the sequence)] Crystal: \ [\a \b \e \f \n \r \t \v \' \" \\] [also (with further chars): \0 \1 \2 \3 \u \x] Excel: [none] [note: uses dual quoting: e.g. "a""b"] Excel VBA: [none] [note: uses dual quoting: e.g. "a""b"] [also: vbBack vbCr vbCrLf vbFormFeed vbLf vbNullChar vbTab vbVerticalTab] Go: \ [\a \b \f \n \r \t \v \' \" \\] [also (with further chars): \0 \1 \2 \3 \u \U \x] Java: \ [\b \f \n \r \t \' \" \\] [also (with further chars): \u] [MAJOR WARNING: Java replaces escaped chars, including in comments, before parsing the source code] [e.g. myvar = "\u0022" resolves to myvar = """, which is invalid, workaround: myvar = "\u005C\u0022" resolves to myvar = "\""] JavaScript: \ [\b \f \n \r \t \v \' \" \\ \0] [also (with further chars): \u \x] [note: \ followed by a line break gives a blank string] Kotlin: \ [\b \n \r \t \' \" \\ \$] [also (with further chars): \u] PHP: \ [\e \f \n \r \t \v \' \" \\ \$] [also (with further chars): \0 \1 \2 \3 \4 \5 \6 \7 \u \x] [note: for single quotes, \' and \\ are the only escape sequences] Python: \ [\b \f \n \r \t \' \" \\] [also (with further chars): \o \u \U \x] R: \ [\a \b \f \n \r \t \v \' \" \\] [also (with further chars): \0 \1 \2 \3 \4 \5 \6 \7 \u \U \x] Ruby: \ [\a \b \e \f \n \r \s \t \v \' \" \\] [also (with further chars): \0 \1 \2 \3 \4 \5 \6 \7 \C \c \M \u \x] [note: for single quotes, \' and \\ are the only escape sequences] Rust: \ [\n \r \t \' \" \\ \0] [also (with further chars): \u \x] Scala: \ [\b \f \n \r \t \' \" \\] [also (with further chars): \u] [MAJOR WARNING: Scala replaces escaped chars, including in comments, before parsing the source code] [deprecated (octals, with further chars): \0 \1 \2 \3] SQL (MySQL): \ [\b \n \r \t \Z \' \\ \0] [also: dual quoting: e.g. 'a''b'] [also (when pattern-matching with LIKE): \% \_] [also (linefeed): '' with a literal linebreak in-between (press enter)] [e.g. equivalent to 'a\nb': 'a\nb'] SQL (PostgreSQL): \ [\b \f \n \r \t \' \\] [MAJOR WARNING: requires E/e prefix, e.g. E'\n', e.g. e'\n'] [also (with further chars): \0 \1 \2 \3 \4 \5 \6 \7 \u \U \x] [note: uses dual quoting: e.g. 'a''b'] [also (linefeed): '' with a literal linebreak in-between (press enter)] [e.g. equivalent to 'a\nb': E'a\nb'] [note: from PostgreSQL 9.1 onwards, 'standard_conforming_strings' is set to on, i.e. '\' is treated literally, use the 'E' prefix, e.g. E'\n', to use '\' as an escape char, to get/set this value: SELECT setting FROM pg_settings WHERE name = 'standard_conforming_strings'; SET standard_conforming_strings = on;] SQL (SQLite): [none] [note: uses dual quoting: e.g. 'a''b'] [also (linefeed): x'0a', char(10), '' with a literal linebreak in-between (press enter)] [e.g. equivalent to 'a\nb': 'a'||char(10)||'b'] Swift: \ [\n \r \t \' \" \\ \0] [also (with further chars): \u] UFL: SymVerbatim [or SymRaw][create a raw/verbatim string literal][note: based on 'abc' examples in 'Timeline of New Features'][see also: StringNewDemoAsciiVerbatim/StrMultiLineDemo] AutoHotkey: [can use: continuation section: replace pilcrows with line breaks: vText := "¶(¶abc¶)"] C++: R"(abc)", R"mytag(abc)mytag" C#: """abc""", """"abc"""", """""abc""""" [also: @"abc"] Crystal: %q(abc), %q[abc], %q{abc}, %q!abc! Excel: [none] Excel VBA: [none] Go: `abc` Java: """\u000Aabc""" [note: where '\u000A' becomes a line break, that isn't part of the string] JavaScript: `abc`, String.raw`abc` Kotlin: """abc""", $$"""abc""" [note ($$): multi-dollar interpolation: use 2 or more dollar signs, e.g. use '$$' to make '$$' do interpolation, not '$'] PHP: [can use: Nowdoc: replace pilcrows with line breaks: <<<'mytag'¶abc¶mytag;] Python: r"abc", r"""abc""", r'abc', r'''abc''' R: r"(abc)", r"[abc]", r"{abc}", r"--(abc)--", r"---(abc)---" Ruby: %q(abc), %q[abc], %q{abc}, %q!abc! Rust: r#"abc"#, r##"abc"##, r###"abc"### Scala: """abc""" SQL (MySQL): [none] SQL (PostgreSQL): $$abc$$, $mytag$abc$mytag$ SQL (SQLite): [none] Swift: #"abc"#, ##"abc"##, ###"abc"### UFL: SymInterpolateVarDemo [string interpolation, e.g. literal text and a variable name][see also: Format/SymCharApos] AutoHotkey: [none] [can use: Format("Hello, {}!", name)] [also (single quotes, AHK v2 onwards): Format('Hello, {}!', name)] C++: [none] [can use: std::format("Hello, {}!", name)] [requires: #include <format>] [note: single quote is used for chars] C#: $"Hello, {name}!" [note: single quote is used for chars] Crystal: "Hello, #{name}!" [WARNING: # is a special character in string literals] [note: single quote is used for chars] Excel: [none] Excel VBA: [none] Go: [none] [can use: fmt.Sprintf("Hello, %v!", name)] [note: single quote is used for chars] Java: [none] [can use: String.format("Hello, %s!", name)] [note: single quote is used for chars] JavaScript: `Hello, ${name}!` Kotlin: "Hello, ${name}!" [also: "Hello, $name!"] [WARNING: $ is a special character in string literals] [note: single quote is used for chars] PHP: "Hello, {$name}!" [also: "Hello, $name!"] [e.g. array value: "Hello, {$oArray[0]}!"] [WARNING: $ is a special character in string literals] [note: doesn't work with single quotes (although ' is used for strings)] [deprecated: "Hello, ${name}!"] Python: f"Hello, {name}!" [also (single quotes): f'Hello, {name}!'] R: [none] [can use: sprintf("Hello, %s!", name)] [also (single quotes): sprintf('Hello, %s!', name)] Ruby: "Hello, #{name}!" [WARNING: # is a special character in string literals] [note: doesn't work with single quotes (although ' is used for strings)] Rust: [none] [can use: format!("Hello, {name}!")] [note: single quote is used for chars] Scala: s"Hello, ${name}!" [also: s"Hello, $name!"] [note: single quote is used for chars] SQL (MySQL): [none] SQL (PostgreSQL): [none] SQL (SQLite): [none] Swift: "Hello, \(name)!" [note: doesn't work with single quotes (' is not used for strings or chars)] UFL: SymInterpolateXpnDemo [string interpolation, e.g. literal text and an arbitrary expression, prints 'Hello, 579!'][see also: Format/SymCharApos] AutoHotkey: [none] [can use: Format("Hello, {}!", 123+456)] [also (single quotes, AHK v2 onwards): Format('Hello, {}!', 123+456)] C++: [none] [can use: std::format("Hello, {}!", 123+456)] [requires: #include <format>] [note: single quote is used for chars] C#: $"Hello, {123+456}!" [note: single quote is used for chars] Crystal: "Hello, #{123+456}!" [WARNING: # is a special character in string literals] [note: single quote is used for chars] Excel: [none] Excel VBA: [none] Go: [none] [can use: fmt.Sprintf("Hello, %v!", 123+456)] [note: single quote is used for chars] Java: [none] [can use: String.format("Hello, %s!", 123+456)] [note: single quote is used for chars] JavaScript: `Hello, ${123+456}!` Kotlin: "Hello, ${123+456}!" [WARNING: $ is a special character in string literals] [note: single quote is used for chars] PHP: [none] [can use: sprintf("Hello, %d!", 123+456)] [WARNING: $ is a special character in string literals] [note: doesn't work with single quotes (although ' is used for strings)] [WARNING: the '$var'/'{$var}' interpolation syntax doesn't handle arbitrary expressions] Python: f"Hello, {123+456}!" [also (single quotes): f'Hello, {123+456}!'] R: [none] [can use: sprintf("Hello, %s!", 123+456)] [also (single quotes): sprintf('Hello, %s!', 123+456)] Ruby: "Hello, #{123+456}!" [WARNING: # is a special character in string literals] [note: doesn't work with single quotes (although ' is used for strings)] Rust: [none] [can use: format!("Hello, {}!", 123+456)] [note: single quote is used for chars] Scala: s"Hello, ${123+456}!" [note: single quote is used for chars] SQL (MySQL): [none] SQL (PostgreSQL): [none] SQL (SQLite): [none] Swift: "Hello, \(123+456)!" [note: doesn't work with single quotes (' is not used for strings or chars)] UFL: OpPow [power (exponent)][see also: Pow/OpPrecPowUnarySubDemo] AutoHotkey: ** C++: [none] [can use: pow(vNum1, vNum2)] C#: [none] [can use: Math.Pow(vNum1, vNum2)] Crystal: ** Excel: ^ Excel VBA: ^ Go: [none] [can use: math.Pow(vNum1, vNum2)] [requires: import "math"] Java: [none] [can use: Math.pow(vNum1, vNum2)] JavaScript: ** Kotlin: [none] [can use: Math.pow(vNum1, vNum2)] PHP: ** Python: ** R: ** [also: ^] Ruby: ** Rust: [none] [can use: vNum1.pow(vNum2)] Scala: [none] [can use: math.pow(vNum1, vNum2)] SQL (MySQL): [none] [can use: pow(MyNum1, MyNum2)] SQL (PostgreSQL): ^ [also: pow(MyNum1, MyNum2)] SQL (SQLite): [none] [can use: pow(MyNum1, MyNum2)] Swift: [none] [can use: pow(vNum1, vNum2)] [requires: import Foundation] UFL: SymComment [single-line comment][see also: SymCommentMult] AutoHotkey: ; C++: // C#: // Crystal: # Excel: [none] [can use: N("my comment") returns 0, T(N("my comment")) returns "", LET()] Excel VBA: ' Go: // Java: // JavaScript: // Kotlin: // PHP: // [also: #] Python: # R: # Ruby: # Rust: // [WARNING: /// and //! are doc comments] Scala: // SQL (MySQL): -- [note: -- must be followed by space/tab/linefeed etc] [also: #] SQL (PostgreSQL): -- SQL (SQLite): -- Swift: // UFL: SymCommentMult [multi-line comments][note: also work as single-line comments][see also: SymComment] AutoHotkey: /* */ [WARNING: /* only works at the start of a line] [WARNING: */ only works at the start/end of a line] [note: these rules differ for AHK v1/v2] C++: /* */ C#: /* */ Crystal: [none] Excel: [none] Excel VBA: [none] Go: /* */ Java: /* */ JavaScript: /* */ Kotlin: /* */ PHP: /* */ Python: [none] [note: workaround: bare string literals can be used as comments: ''' """] R: [none] Ruby: =begin =end [WARNING: only work at the start of a line] Rust: /* */ Scala: /* */ SQL (MySQL): /* */ SQL (PostgreSQL): /* */ SQL (SQLite): /* */ Swift: /* */ UFL: OpConcat [concatenate][see also: StrConcat/StrIntConcat] AutoHotkey: . [also: implicit string concatenation (auto-concat) (e.g. '"abc" "def" 123 myvar' is equivalent to '"abcdef123" myvar')] C++: + [WARNING: + for addition and concatenation] [also: string literal concatenation (implicit string concatenation) (e.g. '"abc" "def"' is equivalent to '"abcdef"')] C#: + [WARNING: + for addition and concatenation] Crystal: + [WARNING: + for addition and concatenation] Excel: & Excel VBA: & [also: +] [WARNING: + for addition and concatenation] Go: + [WARNING: + for addition and concatenation] Java: + [WARNING: + for addition and concatenation] JavaScript: + [WARNING: + for addition and concatenation] Kotlin: + [WARNING: + for addition and concatenation] PHP: . Python: + [WARNING: + for addition and concatenation] [also: implicit string concatenation (e.g. '"abc" "def"' is equivalent to '"abcdef"')] R: [none] [can use: paste0(vText1, vText2)] [also: paste(vText1, vText2, sep="")] Ruby: + [WARNING: + for addition and concatenation] [also: implicit string concatenation (e.g. '"abc" "def"' is equivalent to '"abcdef"')] Rust: + [WARNING: + for addition and concatenation] Scala: + [WARNING: + for addition and concatenation] SQL (MySQL): || [MAJOR WARNING: use 'set sql_mode=PIPES_AS_CONCAT' to enable pipes as concat] [WARNING: unusual operator symbol] [WARNING: concatenates ints (not just strings)] [also: concat()] [also: implicit string concatenation (e.g. "'abc' 'def'" is equivalent to "'abcdef'")] SQL (PostgreSQL): || [WARNING: unusual operator symbol] [WARNING: at least one operand must be a string] [also: concat()] SQL (SQLite): || [WARNING: unusual operator symbol] [WARNING: concatenates ints (not just strings)] [also: concat()] Swift: + [WARNING: + for addition and concatenation] UFL: OpLTStr/OpGTStr [string comparison (less than/greater than)][e.g. "A" > "a" should return false, and "A" < "a" true, since 65 < 97][see also: StrCompare] AutoHotkey: [none] [can use: StrCompare()] [WARNING (StrCompare): case-insensitive by default] C++: < > [e.g. ((std::string)"abc" < (std::string)"def")] [also (for char arrays): strcmp()] C#: [none] [can use: String.Compare()] Crystal: < > Excel: < > [WARNING: case-insensitive] [also (case-sensitive equals): =EXACT(A1,B1)] Excel VBA: < > [note: case-sensitive (unlike sheet versions of < and >)] Go: < > Java: [none] [can use: compareTo()] JavaScript: < > Kotlin: < > PHP: < > Python: < > R: < > [WARNING: 'vText1 > vText2' may give an unintuitive result depending on the default collation] [note: for a more standard comparison, use locale 'C', e.g. Sys.setlocale("LC_COLLATE", "C")] Ruby: < > Rust: < > Scala: < > SQL (MySQL): < > [WARNING: case-insensitive] SQL (PostgreSQL): < > [e.g. MyCol1 > MyCol2 COLLATE "C"] [WARNING: 'MyCol1 > MyCol2' may give an unintuitive result depending on the default collation] SQL (SQLite): < > Swift: < > UFL: OpEquals [comparison (equality)][see also: StrEquals/DateClone/Any.Address] AutoHotkey: == [also (case-insensitive): =] C++: == [e.g. ((std::string)"abc" == (std::string)"def")] [also (for char arrays): strcmp()] C#: == Crystal: == Excel: = [note: case-insensitive] Excel VBA: = [case-sensitive (unlike Excel sheet formulae)] Go: == Java: == [note: == checks for referential equality] [also (compare values): oObj1.equals(oObj2)] JavaScript: == [also (strict equal): ===] [note (===): operands are equal and of the same type] Kotlin: == [also (referential equality): ===] PHP: == [also: ===] [note (==): equal after type juggling] Python: == [also (referential equality): is (inverse: is not)] [note: word order: 'not in' versus 'is not'] R: == Ruby: == [also (type-sensitive): oObj1.eql?(oObj2)] [also (compares object IDs, referential equality): oObj1.equal?(oObj2)] Rust: == Scala: == [also (referential equality): eq (inverse: ne)] SQL (MySQL): = [WARNING: case-insensitive] [also (null-safe equal): <=>] [WARNING: <=> does not do three-way comparison] SQL (PostgreSQL): = SQL (SQLite): = [also: ==] Swift: == UFL: OpNotEquals [comparison (not equals)] AutoHotkey: !== [note: case-insensitive: !=] [deprecated (AHK v1): <> (*case-insensitive* when comparing strings)] C++: != [e.g. ((std::string)"abc" != (std::string)"def")] [also (for char arrays): strcmp()] C#: != Crystal: != Excel: <> Excel VBA: <> [note: case-sensitive (unlike Excel sheet formulae)] Go: != Java: != JavaScript: != [also (strict not equal): !==] [note (!==): operands are of the same type but not equal, or are of different type] Kotlin: != [also (referential equality negated counterpart): !==] PHP: != [also: !==] [also: <>] [note (!= <>): not equal after type juggling] Python: != R: != Ruby: != Rust: != Scala: != SQL (MySQL): <> [also: !=] [WARNING (<> and !=): case-insensitive] SQL (PostgreSQL): <> [also: !=] SQL (SQLite): <> [also: !=] Swift: != UFL: OpInc [increment] AutoHotkey: i++ ++i i+=1 C++: i++ ++i i+=1 C#: i++ ++i i+=1 Crystal: i+=1 Excel: [none] Excel VBA: [none] [can use: i = i + 1] Go: i++ i+=1 Java: i++ ++i i+=1 JavaScript: i++ ++i i+=1 Kotlin: i++ ++i i+=1 PHP: $i++ ++$i $i+=1 Python: i+=1 R: [none] [can use: i = i + 1] Ruby: i+=1 [WARNING: the one-liner ++i is a noop, it returns i and discards it] [WARNING: the one-liner i++ tries to combine with the line underneath] Rust: i+=1 Scala: i+=1 SQL (MySQL): [none] SQL (PostgreSQL): [none] SQL (SQLite): [none] Swift: i+=1 [deprecated (removed in v3.0): i++ ++i] UFL: OpDec [decrement] AutoHotkey: i-- --i i-=1 C--: i-- --i i-=1 C#: i-- --i i-=1 Crystal: i-=1 Excel: [none] Excel VBA: [none] [can use: i = i - 1] Go: i-- i-=1 Java: i-- --i i-=1 JavaScript: i-- --i i-=1 Kotlin: i-- --i i-=1 PHP: $i-- --$i $i-=1 Python: i-=1 R: [none] [can use: i = i - 1] Ruby: i-=1 [WARNING: the one-liner --i is a noop, it returns i and discards it] [WARNING: the one-liner i-- tries to combine with the line underneath] Rust: i-=1 Scala: i-=1 SQL (MySQL): [none] SQL (PostgreSQL): [none] SQL (SQLite): [none] Swift: i-=1 [deprecated (removed in v3.0): i-- --i] UFL: OpSubSubOrDecDemo [i.e. -- could be decrement or 'subtract subtract'][-- (applied to integer literals e.g. 15--10 = 25) (i.e. apply - twice) (i.e. binary minus then unary minus)] AutoHotkey: ___ [error] [WARNING: AHK v1: 15--10 returns 10, it should return 25] C++: ___ [error] C#: ___ [error] Crystal: ___ [error] Excel: works Excel VBA: works [note: '15--10' is auto-formatted to '15 - -10'] Go: ___ [error] Java: ___ [error] JavaScript: ___ [error] Kotlin: ___ [error] PHP: ___ [error] Python: works R: works Ruby: works Rust: works Scala: ___ [error] SQL (MySQL): works SQL (PostgreSQL): ___ [error] [WARNING: '15--10' is interpreted as '15' because '--' indicates a comment] [note: '15 - -10' returns 25 as expected] SQL (SQLite): ___ [error] [WARNING: '15--10' is interpreted as '15' because '--' indicates a comment] [note: '15 - -10' returns 25 as expected] Swift: ___ [error] UFL: OpAssign [assign][see also: SymCharEq] AutoHotkey: := [note (in AHK v1, sometimes): =] C++: = C#: = Crystal: = Excel: = [also: equals (comparison)] [note: *case-insensitive* when comparing strings] Excel VBA: = [also: equals (comparison) (case-sensitive when comparing strings)] Go: = [also (declare-and-assign one-liners): :=] [note: = to declare-and-assign or assign] Java: = JavaScript: = Kotlin: = PHP: = Python: = [also (sometimes): :=] R: <- [also: =] [also (non-local assignment operator, 'global assignment operator'): <<-] Ruby: = Rust: = Scala: = SQL (MySQL): = [WARNING: = sometimes does comparison] [also (variables): :=] SQL (PostgreSQL): = [WARNING: = sometimes does comparison] [also (stored functions): :=] SQL (SQLite): = [WARNING: = sometimes does comparison] Swift: = UFL: OpAnd [logical and][for some languages: inputs must be bools][for some languages: output is bool, for others: first truthy value] AutoHotkey: && [also: and] [note: takes any, returns value] [WARNING: AHK v1: returns bool] C++: && [note: takes any, returns bool (as int)] [WARNING: "" (char array) is considered truthy] C#: && [note: takes bool, returns bool] Crystal: && [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [note: takes any, returns value] Excel: [none] [can use: =AND(A1,B1)] [note: takes bool/number, returns bool] Excel VBA: And [MAJOR WARNING: does not apply short-circuit Boolean evaluation] [WARNING: bitwise-and when applied to numbers] [note: takes bool/number, returns value] Go: && [note: takes bool, returns bool] Java: && [note: takes bool, returns bool] JavaScript: && [note: takes any, returns value] Kotlin: && [note: takes bool, returns bool] PHP: && [note: takes any, returns bool] Python: and [note: takes any, returns value] R: && [note: takes bool/number, returns bool] [WARNING: && works on the first vector element, & works on all vector elements] Ruby: && [also: and] [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [note: takes any, returns value] [WARNING: 'and' is higher precedence than '&&'] Rust: && [note: takes bool, returns bool] Scala: && [note: takes bool, returns bool] SQL (MySQL): AND [also: &&] [note: takes any, returns bool (as int)] SQL (PostgreSQL): AND [note: takes bool, returns bool] SQL (SQLite): AND [note: takes any, returns bool (as int)] Swift: && [note: takes bool, returns bool] UFL: OpOr [logical or][for some languages: inputs must be bools][for some languages: output is bool, for others: first truthy value] AutoHotkey: || [also: or] [note: takes any, returns value] [WARNING: AHK v1: returns bool] C++: || [note: takes any, returns bool (as int)] [WARNING: "" (char array) is considered truthy] C#: || [note: takes bool, returns bool] Crystal: || [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [note: takes any, returns value] Excel: [none] [can use: =OR(A1,B1)] [note: takes bool/number, returns bool] Excel VBA: Or [MAJOR WARNING: does not apply short-circuit Boolean evaluation] [WARNING: bitwise-or when applied to numbers] [note: takes bool/number, returns value] Go: || [note: takes bool, returns bool] Java: || [note: takes bool, returns bool] JavaScript: || [note: takes any, returns value] Kotlin: || [note: takes bool, returns bool] PHP: || [note: takes any, returns bool] Python: or [note: takes any, returns value] R: || [note: takes bool/number, returns bool] [WARNING: || works on the first vector element, | works on all vector elements] Ruby: || [also: or] [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [note: takes any, returns value] [WARNING: 'or' is higher precedence than '||'] Rust: || [note: takes bool, returns bool] Scala: || [note: takes bool, returns bool] SQL (MySQL): OR [also: ||] [WARNING: || does concatenation if use 'set sql_mode=PIPES_AS_CONCAT'] [note: takes any, returns bool (as int)] SQL (PostgreSQL): OR [WARNING: || does concatenation] [note: takes bool, returns bool] SQL (SQLite): OR [WARNING: || does concatenation] [note: takes any, returns bool (as int)] Swift: || [note: takes bool, returns bool] UFL: OpOrIntDemo [|| (whether it returns a bool or an operand)][i.e. whether it's equivalent to a short-ternary operator][for some languages, cannot use ints with ||][see also: OpShortTern] AutoHotkey: 0 || 123 [output: 123] [note: AHK v1: returns 1 (i.e. True)] C++: 0 || 123 [output: 1 (i.e. True)] C#: 0!=0 || 123!=0 [output: True] Crystal: 0 || 123 [output: 0] [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Excel: OR(0,123) [output: TRUE] Excel VBA: 0 Or 123 [output: 123] [note: bitwise-or] Go: 0 != 0 || 123 != 0 [output: true] Java: 0!=0 || 123!=0 [output: true] JavaScript: 0 || 123 [output: 123] Kotlin: 0!=0 || 123!=0 [output: true] [WARNING: in Kotlin, '?:' is a null-coalescing operator, not a short-ternary operator: e.g. '0 ?: 123' returns 0, since 0 is non-null] PHP: 0 || 123 [output: 1 (i.e. True)] [note: '0 ?: 123' returns 123] Python: 0 or 123 [output: 123] R: 0 || 123 [output: TRUE] Ruby: 0 || 123 [output: 0] [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Rust: 0!=0 || 123!=0 [output: true] Scala: 0!=0 || 123!=0 [output: true] SQL (MySQL): 0 OR 123 [output: 1 (i.e. true)] SQL (PostgreSQL): 0!=0 OR 123!=0 [output: t (i.e. true)] SQL (SQLite): 0 OR 123 [output: 1 (i.e. true)] Swift: 0 != 0 || 123 != 0 [output: true] [note: '0 || 123' is invalid] UFL: OpNot [logical not][see also: IsTruthy] AutoHotkey: ! [also: not] [WARNING: !/not have different operator precedences] [note: takes any, returns bool (as int)] C++: ! [note: takes any, returns bool (as int)] [WARNING: "" (char array) is considered truthy] C#: ! [note: takes bool, returns bool] Crystal: ! [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [note: takes any, returns bool] Excel: [none] [can use: =NOT(A1)] [note: takes bool/number, returns bool] Excel VBA: Not [WARNING: bitwise-not when applied to numbers] [can use (ints): (vValue = 0)] [note: takes bool/number, returns value] Go: ! [note: takes bool, returns bool] Java: ! [note: takes bool, returns bool] JavaScript: ! [note: takes any, returns bool] Kotlin: ! [note: takes bool, returns bool] PHP: ! [note: takes any, returns bool] Python: not [note: takes any, returns bool] R: ! [note: takes bool/number, returns bool] [also: isTRUE(), isFALSE()] Ruby: ! [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [note: takes any, returns bool] Rust: ! [WARNING: bitwise-not when applied to ints] [can use (ints): (vValue == 0)] [WARNING: accepts ints, unlike && and ||] [note: takes bool/int, returns value] Scala: ! [note: takes bool, returns bool] SQL (MySQL): NOT [also: !] [note: takes any, returns bool (as int)] [MAJOR WARNING: in MySQL, some non-blank strings are considered falsy (e.g. 'abc' is falsy, '123abc' is truthy), strings are cast to numeric, then numeric to 1 or 0] SQL (PostgreSQL): NOT [note: takes bool, returns bool] SQL (SQLite): NOT [note: takes any, returns bool (as int)] [MAJOR WARNING: in SQLite, some non-blank strings are considered falsy (e.g. 'abc' is falsy, '123abc' is truthy), strings are cast to numeric, then numeric to 1 or 0] Swift: ! [note: takes bool, returns bool] UFL: OpNotIntDemo [logical not applied to integers (e.g. !123)] AutoHotkey: 0 [note: bool stored as int] C++: 0 [note: bool stored as int] C#: error [note: !true returns false] Crystal: false [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Excel: FALSE [note: NOT(123) returns FALSE] Excel VBA: -124 [WARNING: bitwise-not when applied to numbers] [note: (123 = 0) returns False] Go: error [note: !true returns false] Java: error [note: !true returns false] JavaScript: false Kotlin: error [note: !true returns false] PHP: false Python: False [note: not 123 returns False] R: FALSE Ruby: false [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Rust: -124 [WARNING: bitwise-not when applied to ints] [note: (123 == 0) returns false] Scala: error [note: !true returns false] SQL (MySQL): 0 [note: NOT 123 returns 0 (i.e. false)] SQL (PostgreSQL): error [note: NOT true returns f (i.e. false)] SQL (SQLite): 0 [note: NOT 123 returns 0 (i.e. false)] Swift: error [note: !true returns false] UFL: OpNotStrDemo [logical not applied to strings (e.g. !"abc")] AutoHotkey: 0 [note: bool stored as int] C++: 0 [note: bool stored as int] [WARNING: '!' applied to any char array returns 0] [note: '!' applied to a std::string throws] C#: error [note: !true returns false] Crystal: false [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Excel: error [note: NOT() in Excel returns an error on strings] Excel VBA: error [note: 'Not' in Excel VBA throws on strings] [note: ("abc" = "") returns False] Go: error [note: !true returns false] Java: error [note: !true returns false] JavaScript: false Kotlin: error [note: !true returns false] PHP: false Python: False [note: not "abc" returns False] R: error Ruby: false [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Rust: error [note: ("abc" == "") returns false] Scala: error [note: !true returns false] SQL (MySQL): 1 [note: NOT "abc" returns 1 (i.e. true)] [MAJOR WARNING: in MySQL, some non-blank strings are considered falsy (e.g. 'abc' is falsy, '123abc' is truthy), strings are cast to numeric, then numeric to 1 or 0] SQL (PostgreSQL): error [note: NOT true returns f (i.e. false)] SQL (SQLite): 1 [note: NOT "abc" returns 1 (i.e. true)] [MAJOR WARNING: in SQLite, some non-blank strings are considered falsy (e.g. 'abc' is falsy, '123abc' is truthy), strings are cast to numeric, then numeric to 1 or 0] Swift: error [note: !true returns false] UFL: OpNotNotIntDemo [logical not applied to integers twice (e.g. !!123)] AutoHotkey: 1 [note: bool stored as int] C++: 1 [note: bool stored as int] C#: error [note: !!true returns true] Crystal: true [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Excel: TRUE [note: NOT(NOT(123)) returns TRUE] Excel VBA: 123 [WARNING: bitwise-not when applied to numbers] [note: ((123 = 0) = False) returns True] Go: error [note: !!true returns true] Java: error [note: !!true returns true] JavaScript: true Kotlin: error [note: !!true returns true] PHP: true Python: True [note: not not 123 returns True] R: TRUE Ruby: true [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Rust: 123 [WARNING: bitwise-not when applied to ints] [note: ((123 == 0) == false) returns true] Scala: error [note: !(!true) returns true] SQL (MySQL): 1 [note: NOT NOT 123 returns 1 (i.e. true)] SQL (PostgreSQL): error [note: NOT NOT true returns t (i.e. true)] SQL (SQLite): 1 [note: NOT NOT 123 returns 1 (i.e. true)] Swift: error [note: !(!true) returns true] [WARNING: error if attempt '!!': 'unary operators must not be juxtaposed'] UFL: OpNotNotStrDemo [logical not applied to strings twice (e.g. !!"abc")] AutoHotkey: 1 [note: bool stored as int] C++: 1 [note: bool stored as int] [WARNING: '!' applied to any char array returns 0] [note: '!' applied to a std::string throws] C#: error [note: !!true returns true] Crystal: true [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Excel: error [note: NOT() in Excel returns an error on strings] Excel VBA: error [note: 'Not' in Excel VBA throws on strings] [note: (("abc" = "") = False) returns True] Go: error [note: !!true returns true] Java: error [note: !!true returns true] JavaScript: true Kotlin: error [note: !!true returns true] PHP: true Python: True [note: not not "abc" returns True] R: error Ruby: true [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Rust: error [note: (("abc" == "") == false) returns true] Scala: error [note: !(!true) returns true] SQL (MySQL): 0 [note: NOT NOT "abc" returns 0 (i.e. false)] [MAJOR WARNING: in MySQL, some non-blank strings are considered falsy (e.g. 'abc' is falsy, '123abc' is truthy), strings are cast to numeric, then numeric to 1 or 0] SQL (PostgreSQL): error [note: NOT NOT true returns t (i.e. true)] SQL (SQLite): 0 [note: NOT NOT "abc" returns 0 (i.e. false)] [MAJOR WARNING: in SQLite, some non-blank strings are considered falsy (e.g. 'abc' is falsy, '123abc' is truthy), strings are cast to numeric, then numeric to 1 or 0] Swift: error [note: !(!true) returns true] [WARNING: error if attempt '!!': 'unary operators must not be juxtaposed'] UFL: (OpPrecPowUnarySubDemo) [or OpPrecPowUnaryMinusDemo][confirm whether the power operator has higher precedence than the unary minus (unary subtract) operator][e.g. confirm that (-3 ** 2) == -9, the answer given by WolframAlpha][see also: OpPow] AutoHotkey: -9 C++: (no pow operator) C#: (no pow operator) Crystal: 9 [WARNING: -9 expected] [note: differs from Ruby] Excel: 9 [WARNING: -9 expected] [note: differs from Excel VBA] Excel VBA: -9 [note: differs from Excel sheets] Go: (no pow operator) Java: (no pow operator) JavaScript: error [e.g. error message: 'Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence'] Kotlin: (no pow operator) PHP: -9 Python: -9 R: -9 Ruby: -9 Rust: (no pow operator) Scala: (no pow operator) SQL (MySQL): (no pow operator) SQL (PostgreSQL): 9 [WARNING: -9 expected] SQL (SQLite): (no pow operator) Swift: (no pow operator) UFL: (OpPrecBitOrEqualsDemo) [confirm whether the bitwise-or operator has higher precedence than the equals operator][e.g. confirm that (2 | 1 == 3) == true][note: it is an oddity in C that == is of higher precedence than & ^ |][see also: BitOr/OpEquals] AutoHotkey: | has precedence over == C++: == has precedence over | [WARNING: == has higher precedence, '(2 | 1 == 3)' returns 2, however, a compiler warning is given] C#: == has precedence over | [WARNING: == has higher precedence, however '(2 | 1 == 3)' would give 'int | bool', and thus throws] Crystal: | has precedence over == Excel: (no bitwise-or operator) Excel VBA: = has precedence over Or (bitwise and logical) [WARNING: = has higher precedence, '(2 Or 1 = 3)' returns 2] Go: | has precedence over == Java: == has precedence over | [WARNING: == has higher precedence, however '(2 | 1 == 3)' would give 'int | bool', and thus throws] JavaScript: == has precedence over | [WARNING: == has higher precedence, '(2 | 1 == 3)' returns 2] Kotlin: 'or' has precedence over == PHP: == has precedence over | [WARNING: == has higher precedence, '(2 | 1 == 3)' returns 2] Python: | has precedence over == R: (no bitwise-or operator) Ruby: | has precedence over == Rust: | has precedence over == Scala: == has precedence over | [WARNING: == has higher precedence, however '(2 | 1 == 3)' would give 'int | bool', and thus throws] SQL (MySQL): | has precedence over = SQL (PostgreSQL): | has precedence over = SQL (SQLite): | has precedence over == Swift: | has precedence over == UFL: OpFuncAnon [or OpAnonFunc][operator/symbol for creating an anonymous function][see also: MakeFuncMapDemoDouble/Array.MapBlock] AutoHotkey: => C++: [] [note: uses '[]', possibly with variable names inside, to refer to external variables] C#: => Crystal: -> [also: blocks use '|' for the input params] Excel: [none] Excel VBA: [none] Go: [none] Java: -> JavaScript: => Kotlin: -> PHP: => [note: and the keyword 'fn'] Python: : [note: and the keyword 'lambda'] [also: list comprehensions, inside square brackets] R: \ Ruby: -> [also: blocks use '|' for the input params] Rust: -> [note: and the keyword 'fn'] [also: blocks use '|' for the input params] Scala: => SQL (MySQL): [none] SQL (PostgreSQL): [none] SQL (SQLite): [none] Swift: -> UFL: OpMemberAccess [member access][property access][see also: Object.GetDemo/Object.SetDemo] AutoHotkey: . C++: . [also (if pointer to an object): ->] [also (class (static) members): ::] C#: . Crystal: . [also (class (static) members): ::] Excel: [none] Excel VBA: . Go: . Java: . JavaScript: . Kotlin: . PHP: -> [also (class (static) members): ::] Python: . R: $ [also: @] [note: $ for S3 class and reference class] [note: @ for S4 class] [also (to set a property value in a method): <<-] Ruby: . [also (class (static) members): ::] Rust: . [also (class (static) members): ::] Scala: . SQL (MySQL): [none] [also (JSON strings): -> and ->>] SQL (PostgreSQL): [none] [also (JSON strings): -> and ->>] SQL (SQLite): [none] [also (JSON strings): -> and ->>] Swift: . UFL: OpSafeNav [or OpNullChain][safe navigation operator (optional chaining operator)][e.g. if a member contains null, return null, i.e. do an early exit, don't attempt to read any descendant members][note: typically, if a member exists and contains null, early exit return null, if a member doesn't exist, throw][e.g. (from Wikipedia): name = article?.author?.name][e.g. a?.b?.c, a may be null (early exit), a.b may be null (early exit), a.b.c may be null] AutoHotkey: [none] C++: [none] C#: ?. [e.g. vValue = oObj?.MyProp] [e.g. vValue = oArray?[vKey]] [e.g. vValue = oFunc?.Invoke(vArg1, vArg2, vArg3)] [name: null-conditional member access operator] Crystal: ___ [can use: '.try &.', e.g. a.try &.b.try &.c] [e.g. vValue = oObj.try &.MyProp] [note: no subscript shorthand] [e.g. vValue = oFunc.try &.call(vArg1, vArg2, vArg3)] Excel: [none] Excel VBA: [none] Go: [none] Java: [none] JavaScript: ?. [e.g. vValue = oObj?.MyProp] [e.g. vValue = oArray?.[vKey]] [e.g. vValue = oFunc?.(vArg1, vArg2, vArg3)] [name: optional chaining operator] Kotlin: ?. [e.g. vValue = oObj?.MyProp] [e.g. vValue = oArray?.get(vKey)] [e.g. vValue = oFunc?.invoke(vArg1, vArg2, vArg3)] [name: safe call operator] [e.g. array of nullable ints: var oArray = arrayOf<Int?>(1, 2, 3)] [e.g. nullable function: var oFunc: ((Int) -> Int)? = {vNum:Int -> vNum*2}] PHP: ?-> [e.g. $vValue = $oObj?->MyProp] [note: no subscript shorthand] [note: no function call shorthand] [name: null-safe operator] Python: [none] R: [none] Ruby: &. [e.g. vValue = oObj&.MyProp] [note: no subscript shorthand] [e.g. vValue = oFunc&.call(vArg1, vArg2, vArg3)] [name: safe navigation operator] Rust: [none] [can use (acts like a return if sees a None, e.g. '?.'): ?] [also: oOpt.map()] [also: oOpt.and_then()] Scala: [none] SQL (MySQL): [none] SQL (PostgreSQL): [none] SQL (SQLite): [none] Swift: ?. [e.g. vValue = oObj?.MyProp] [e.g. (optional subscript operator): oArray?[vKey]] [e.g. (optional call): vValue = oFunc?(vArg1, vArg2, vArg3)] [name: optional chaining operator] [e.g. nullable struct: var oObj:MyStruct? = MyStruct()] [e.g. nullable array of nullable ints: oArray:[Int?]? = [1,2,3]] [e.g. nullable function: var oFunc: ((_ vNum: Int) -> Int)? = {vNum in vNum*2}] UFL: SymPfxBin/SymPfxOct/SymPfxHex [prefixes for bin/oct/hex numbers][binary/octal/hexadecimal] AutoHotkey: [none]/[none]/0x C++: 0b/0/0x [WARNING: a leading '0' is a prefix for octal] C#: 0b/[none]/0x Crystal: 0b/0o/0x Excel: [none]/[none]/[none] [can use: BIN2DEC()/OCT2DEC()/HEX2DEC()] Excel VBA: [none]/&O/&H [can use: WorksheetFunction.Bin2Dec(vBin)] [note: Visual Basic 2017 has &B] [note: WorksheetFunction.Bin2Dec/Application.WorksheetFunction.Bin2Dec return a String, Application.Bin2Dec returns a Double] Go: 0b/0o(or 0)/0x [WARNING: a leading '0' is a prefix for octal] Java: 0b/0/0x [WARNING: a leading '0' is a prefix for octal] JavaScript: 0b/0o(or 0)/0x [WARNING: a leading '0' is a prefix for octal] [MAJOR WARNING: an int starting with '0': including '8'/'9' (invalid octal digits) is treated as dec, e.g. 018 = 18, else treated as octal, e.g. 010 = 8] [WARNING: Number("010") and parseFloat("010") both return 10, not 8] [note: 'Strict mode forbids a 0-prefixed octal literal.'] Kotlin: 0b/[none]/0x PHP: 0b/0o(or 0)/0x [WARNING: a leading '0' is a prefix for octal] Python: 0b/0o/0x R: [none]/[none]/0x Ruby: 0b/0o(or 0)/0x [WARNING: a leading '0' is a prefix for octal] Rust: 0b/0o/0x Scala: [none]/[none]/0x SQL (MySQL): 0b/[none]/0x [MAJOR WARNING: '0b' and '0x' prefixes create strings, use vNum + 0 to cast to a number] [also: B'10' and X'10', which also produce strings] SQL (PostgreSQL): 0b/0o/0x [WARNING: '0b'/'0o'/'0x' support added in PostgreSQL v16.0, before that, 'SELECT 0b10'/'SELECT 0o10'/'SELECT 0x10' all printed '0' (they throw in PostgreSQL v15)] SQL (SQLite): [none]/[none]/0x Swift: 0b/0o/0x UFL: (SymPfxOctZeroDemo) [octal via leading zero demo: does '010' resolve to 10 (dec) or 8 (octal) or throw (or something else)] AutoHotkey: MsgBox(010) [output: 10] C++: std::cout << 010 << "\n" [output: 8] [note: '018' throws] C#: Console.WriteLine(010) [output: 10] Crystal: p 010 [output: throws] Excel: =010 [output: 10] [note: auto-formatted to '=10'] Excel VBA: Debug.Print 010 [output: 10] Go: fmt.Println(010) [output: 8] [note: '018' throws] Java: System.out.println(010) [output: 8] [note: '018' throws] JavaScript: console.log(010) [output: 8] [MAJOR WARNING: '018' doesn't throw, it's treated as dec (base 10)] [note: 'Strict mode forbids a 0-prefixed octal literal.'] Kotlin: println(010) [output: throws] PHP: var_export(010) [output: 8] [note: '018' throws] Python: print(010) [output: throws] R: print(010) [output: 10] Ruby: p 010 [output: 8] [note: '018' throws] Rust: println!("{}", 010) [output: 10] Scala: println(010) [output: throws] SQL (MySQL): SELECT 010 [output: 10] SQL (PostgreSQL): SELECT 010 [output: 10] SQL (SQLite): SELECT 010 [output: 10] Swift: print(010) [output: 10] UFL: SymSepNum [numeric literal separator (digit separator)][break up long numbers (for better readability)] AutoHotkey: [none] [can use: vNum := Number(StrReplace("1_234_567", "_"))] C++: ' C#: _ Crystal: _ Excel: [none] [can use: =0+SUBSTITUTE("1_234_567","_","")] Excel VBA: [none] [can use: vNum = 0 + Replace("1_234_567", "_", "")] [note: Visual Basic 2017 has _] Go: _ Java: _ JavaScript: _ Kotlin: _ PHP: _ Python: _ R: [none] [can use: vNum = as.numeric(gsub("_", "", "1_234_567"))] Ruby: _ Rust: _ Scala: _ SQL (MySQL): [none] SQL (PostgreSQL): _ SQL (SQLite): _ Swift: _
UFL: SymCharSlash [/][note: / and \ are used as dir separators in file paths] AutoHotkey: true division C++: true division [note: truncated division for ints] C#: true division [note: truncated division for ints] Crystal: true division Excel: true division Excel VBA: true division Go: true division [note: truncated division for ints] Java: true division [note: truncated division for ints] JavaScript: true division [used to delimit regular expressions] Kotlin: true division [note: truncated division for ints] PHP: true division [used to delimit regular expressions within double quotes] Python: true division [deprecated: Python 1 and 2: floor division for ints] R: true division Ruby: true division [note: floor division for ints] Rust: true division [note: truncated division for ints] Scala: true division [note: truncated division for ints] SQL (MySQL): true division SQL (PostgreSQL): true division [note: truncated division for ints] SQL (SQLite): true division [note: truncated division for ints] Swift: true division [note: truncated division for ints] UFL: SymCharSlashInt [/ (applied to integers)][typically true division, or C-style integer division (truncated division): divide then round towards zero (truncate)][see also: TrueDiv/TruncDiv/FloorDiv] AutoHotkey: true division C++: truncated division [WARNING: not true division] C#: truncated division [WARNING: not true division] Crystal: true division Excel: true division Excel VBA: true division Go: truncated division [WARNING: not true division] Java: truncated division [WARNING: not true division] JavaScript: true division Kotlin: truncated division [WARNING: not true division] PHP: true division Python: true division [note: Python 1 and 2: floor division] R: true division Ruby: floor division [WARNING: not true division] Rust: truncated division [WARNING: not true division] Scala: truncated division [WARNING: not true division] SQL (MySQL): true division SQL (PostgreSQL): truncated division [WARNING: not true division] SQL (SQLite): truncated division [WARNING: not true division] Swift: truncated division [WARNING: not true division] UFL: SymCharSlashFloat [/ (applied to floats)][see also: TrueDiv] AutoHotkey: true division C++: true division C#: true division Crystal: true division Excel: true division Excel VBA: true division Go: true division Java: true division JavaScript: true division Kotlin: true division PHP: true division Python: true division R: true division Ruby: true division Rust: true division Scala: true division SQL (MySQL): true division SQL (PostgreSQL): true division SQL (SQLite): true division Swift: true division UFL: SymCharSlashSlash [//][see also: SymComment] AutoHotkey: truncated division [note: in AHK v1: sometimes floor division] C++: comment C#: comment Crystal: floor division Excel: ___ Excel VBA: ___ Go: comment Java: comment JavaScript: comment Kotlin: comment PHP: comment Python: floor division R: ___ Ruby: ___ Rust: comment Scala: comment SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: comment UFL: SymCharPct [%][note: typically C-style modulo (truncated modulo)][note: % often has a special meaning in printf/format strings][see also: Mod/FloorMod] AutoHotkey: dynamic variable names (whole or part) [can use (truncated modulo, ints/floats): Mod(vNum1, vNum2)] [deprecated: AHK v1: force expression (use function-style syntax within a command param)] C++: truncated modulo [note: ints only] C#: truncated modulo [note: ints/floats] Crystal: floor modulo [WARNING: % as floor modulo is uncommon] [note: ints/floats] [WARNING: mathematical operator used on strings: % also performs sprintf] Excel: ___ [can use (floor modulo, ints/floats): =MOD(A1,B1)] [WARNING: Excel's MOD() is a floor mod, Excel VBA's Mod operator is a truncated mod] Excel VBA: ___ [can use (truncated modulo, Mod operator, for safety use ints only): vNum1 Mod vNum2] [MAJOR WARNING: Mod operator rounds operands before calculating (note: Excel's sheet function MOD() does not do this)] [also: data type suffix: Integer (%)] Go: truncated modulo [note: ints only] Java: truncated modulo [note: ints/floats] JavaScript: truncated modulo [note: ints/floats] Kotlin: truncated modulo [note: ints/floats] PHP: truncated modulo [note: for safety use ints only] [MAJOR WARNING: % truncates operands before calculating] Python: floor modulo [WARNING: % as floor modulo is uncommon] [note: ints/floats] [WARNING: mathematical operator used on strings: % is also the string formatting operator] R: ___ [note (%%): floor modulo, ints/floats: e.g. vNum1 %% vNum2] Ruby: floor modulo [WARNING: % as floor modulo is uncommon] [note: ints/floats] [WARNING: mathematical operator used on strings: % also performs sprintf] Rust: truncated modulo [note: ints/floats] Scala: truncated modulo [note: ints/floats] SQL (MySQL): truncated modulo, LIKE (matches 0 or more chars) [note: ints/floats] [also: MOD operator] [also: mod()] SQL (PostgreSQL): truncated modulo, LIKE (matches 0 or more chars) [note: ints/floats] [also: mod()] SQL (SQLite): truncated modulo, LIKE (matches 0 or more chars) [note: for safety use ints only] [MAJOR WARNING: % truncates operands before calculating] [also: mod()] Swift: truncated modulo [note: ints only] UFL: SymCharApos [or SymCharSQ/SymCharApostrophe]['][single quotes, apostrophes][see also: SymCharLiteral/SymStringLiteral/SymInterpolateVarDemo/JsonArrayDemo/JsonObjectDemo] AutoHotkey: string literals [note: AHK v2 onwards] C++: characters [note: ' is also a digit separator] C#: characters Crystal: characters Excel: ___ Excel VBA: comments Go: characters Java: characters JavaScript: string literals Kotlin: characters PHP: string literals Python: string literals R: string literals Ruby: string literals Rust: characters Scala: characters SQL (MySQL): string literals [also: "] [note: ` is used for identifiers (e.g. column names)] SQL (PostgreSQL): string literals [WARNING: double quotes are used for identifiers (e.g. column names)] SQL (SQLite): string literals [WARNING: double quotes are used for column names] Swift: ___ UFL: SymCharEq [=][see also: OpAssign] AutoHotkey: equals [note: *case-insensitive* when comparing strings] C++: assign C#: assign, anonymous types (e.g. oObj = new {p1="v1"}) Crystal: assign Excel: assign [also: equals (comparison)] [note: *case-insensitive* when comparing strings] Excel VBA: assign [also: equals (comparison)] [note: case-sensitive (not case-insensitive) when comparing strings] Go: assign [also (declare-and-assign one-liners): :=] [note: = to declare-and-assign or assign] Java: assign JavaScript: assign Kotlin: assign PHP: assign Python: assign R: assign, name-value pairs (e.g. oVec = c("k1"="v1")) [also (assign): <-] Ruby: assign Rust: assign Scala: assign SQL (MySQL): assign [also: comparison] SQL (PostgreSQL): assign [also: comparison] SQL (SQLite): assign [also: comparison] Swift: assign UFL: SymCharColonEq [:=][see also: OpAssign] AutoHotkey: assignment, function parameter default values C++: ___ C#: ___ Crystal: ___ Excel: ___ Excel VBA: function call named parameters Go: declare-and-assign one-liners Java: ___ JavaScript: ___ Kotlin: ___ PHP: ___ Python: assignment within an expression (e.g. if-statement/while loop) [note: walrus operator] R: ___ Ruby: ___ Rust: ___ Scala: ___ SQL (MySQL): assignment (e.g. in SET/SELECT/UPDATE statements) SQL (PostgreSQL): assignment in PL/pgSQL (stored procedures/stored functions) [deprecated: function call named parameters] SQL (SQLite): ___ Swift: ___ UFL: SymCharEqEq [==] AutoHotkey: equals [note: case-sensitive when comparing strings] C++: equals C#: equals Crystal: equals Excel: ___ Excel VBA: ___ Go: equals Java: equals JavaScript: equals Kotlin: equals PHP: equal after type juggling [note: most languages use a form of 'type juggling' when comparing] Python: equals R: equals Ruby: equals Rust: equals Scala: equals SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): equals Swift: equals UFL: SymCharEqEqEq [===] AutoHotkey: ___ C++: ___ C#: ___ Crystal: case subsumption operator [i.e. is right operand a member of left operand] Excel: ___ Excel VBA: ___ Go: ___ Java: ___ JavaScript: strict equal [note: operands are equal and of the same type] Kotlin: referential equality [note: true iff point to same object] PHP: equal and of the same type Python: ___ R: ___ Ruby: case equality operator [i.e. is right operand a member of left operand] [e.g. used in case statements] Rust: ___ Scala: ___ SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: 'identical to' identity operator [note: this applies to class instances, it is not available for other types, e.g. 'structures and enumerations, ... they're always copied when they're assigned to a constant or variable, or passed to a function'] UFL: SymCharExclEq [!=] AutoHotkey: not equal [note: *case-insensitive* when comparing strings] C++: not equal C#: not equal Crystal: not equal Excel: ___ Excel VBA: ___ Go: not equal Java: not equal JavaScript: not equal Kotlin: not equal PHP: not equal after type juggling Python: not equal R: not equal Ruby: not equal Rust: not equal Scala: not equal SQL (MySQL): not equal SQL (PostgreSQL): not equal SQL (SQLite): not equal Swift: not equal UFL: SymCharExclEqEq [!==] AutoHotkey: not equal [note: case-sensitive when comparing strings] C++: ___ C#: ___ Crystal: ___ Excel: ___ Excel VBA: ___ Go: ___ Java: ___ JavaScript: strict not equal [note: operands are of the same type but not equal, or are of different type] Kotlin: referential equality negated counterpart PHP: not equal or not of the same type Python: ___ R: ___ Ruby: ___ Rust: ___ Scala: ___ SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: 'not identical to' identity operator [note: this applies to class instances] UFL: SymCharLtGt [<>] AutoHotkey: ___ [deprecated (AHK v1): not equal (*case-insensitive* when comparing strings)] C++: ___ C#: ___ Crystal: ___ Excel: not equal [note: *case-insensitive* when comparing strings] Excel VBA: not equal [note: case-sensitive when comparing strings] Go: ___ Java: ___ JavaScript: ___ Kotlin: ___ PHP: not equal after type juggling Python: ___ [deprecated (Python v2): not equal] R: ___ Ruby: ___ Rust: ___ Scala: ___ SQL (MySQL): not equal SQL (PostgreSQL): not equal SQL (SQLite): not equal Swift: ___ UFL: SymCharTildeEq [~=][see also: RegExIndex] AutoHotkey: 2-param version of RegExMatch [e.g. vPos := vText ~= vNeedle, equivalent to: vPos := RegExMatch(vText, vNeedle)] C++: ___ C#: ___ Crystal: ___ [note (=~, not ~=): vPos = vText =~ oRegEx, equivalent to: vPos = vText.index(oRegEx)] Excel: ___ Excel VBA: ___ Go: ___ Java: ___ JavaScript: ___ Kotlin: ___ PHP: ___ Python: ___ R: ___ Ruby: ___ [note (=~, not ~=): vPos = vText =~ oRegEx, equivalent to: vPos = vText.index(oRegEx)] Rust: ___ Scala: ___ SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: pattern-matching operator (is value in range) UFL: (SymCharPlusIntStrDemo) [int plus string demo: does it resolve to 12 (concat) or 3 (add) or throw (or something else)][see also: StrIntConcat] AutoHotkey: MsgBox(1 + "2") [output: 3] [note: order matters: "1"+2 throws] [note: . is used for concat] C++: std::cout << "[" << 1 + "2" << "]" << "\n" [output: undefined, warning] [note: throws with std::string("2")] C#: Console.WriteLine(1 + "2") [output: 12] Crystal: p 1 + "2" [output: throws] Excel: =1+"2" [output: 3] [note: & is used for concat] Excel VBA: Debug.Print 1 + "2" [output: 3] [note: both + and & are used for concat] Go: fmt.Println(1 + "2") [output: throws] Java: System.out.println(1 + "2") [output: 12] JavaScript: console.log(1 + "2") [output: 12] Kotlin: println(1 + "2") [output: throws] [note: order matters: "1"+2 concats] PHP: var_export(1 + "2") [output: 3] [note: . is used for concat] Python: print(1 + "2") [output: throws] R: print(1 + "2") [output: throws] Ruby: p 1 + "2" [output: throws] Rust: println!("{}", 1 + "2") [output: throws] Scala: println(1 + "2") [output: 12 (deprecated warning)] SQL (MySQL): SELECT 1 + "2" [output: 3] [note: || is used for concat (if PIPES_AS_CONCAT enabled)] SQL (PostgreSQL): SELECT 1 + "2" [output: throws] [note: || is used for concat] SQL (SQLite): SELECT 1 + "2" [output: 3] [note: || is used for concat] Swift: print(1 + "2") [output: throws] UFL: (SymCharPlusStrIntDemo) [string plus int demo: does it resolve to 12 (concat) or 3 (add) or throw (or something else)][see also: StrIntConcat] AutoHotkey: MsgBox("1" + 2) [output: throws] [note: order matters: 1+"2" sums (adds)] [note: . is used for concat] C++: std::cout << "[" << "1" + 2 << "]" << "\n" [output: undefined, warning] [note: throws with std::string("1")] C#: Console.WriteLine("1" + 2) [output: 12] Crystal: p "1" + 2 [output: throws] Excel: ="1"+2 [output: 3] [note: & is used for concat] Excel VBA: Debug.Print "1" + 2 [output: 3] [note: both + and & are used for concat] Go: fmt.Println("1" + 2) [output: throws] Java: System.out.println("1" + 2) [output: 12] JavaScript: console.log("1" + 2) [output: 12] Kotlin: println("1" + 2) [output: 12] [note: order matters: 1+"2" throws] PHP: var_export("1" + 2) [output: 3] [note: . is used for concat] Python: print("1" + 2) [output: throws] R: print("1" + 2) [output: throws] Ruby: p "1" + 2 [output: throws] Rust: println!("{}", "1" + 2) [output: throws] Scala: println("1" + 2) [output: 12] SQL (MySQL): SELECT "1" + 2 [output: 3] [note: || is used for concat (if PIPES_AS_CONCAT enabled)] SQL (PostgreSQL): SELECT "1" + 2 [output: throws] [note: || is used for concat] SQL (SQLite): SELECT "1" + 2 [output: 3] [note: || is used for concat] Swift: print("1" + 2) [output: throws] UFL: SymCharDot [.][note: '.' is often used as a decimal separator (in some locales ',' is used)][see also: OpMemberAccess/OpConcat] AutoHotkey: member access, string concatenation C++: member access C#: member access Crystal: member access Excel: ___ Excel VBA: member access Go: member access Java: member access JavaScript: member access Kotlin: member access PHP: string concatenation Python: member access R: member access Ruby: member access Rust: member access Scala: member access SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: member access UFL: SymCharDotDot [..][see also: Range.New/Array.SliceRestInfRangeDemo/Range.NewBothDemo] AutoHotkey: ___ C++: ___ C#: spread operator (call only), range (exclusive end) [WARNING (range): exclusive end] [note (range): Range, not RangeIterator] [WARNING (spread operator): 2 dots (not 3)] [WARNING (spread operator): .. doesn't work universally in function calls] Crystal: range (inclusive end) [note: range (exclusive end): ...] Excel: ___ Excel VBA: ___ Go: ___ Java: ___ JavaScript: ___ Kotlin: range (inclusive end) [note: range (exclusive end): ..<] [WARNING: can't do 'oArray.slice(vKey..)'] [note: '..' slices arrays, but doesn't create a range object for iterating] PHP: ___ Python: ___ R: ___ Ruby: range (inclusive end) [note: range (exclusive end): ...] Rust: range (exclusive end) [WARNING: exclusive end] [note: range (inclusive end): ..=] Scala: ___ SQL (MySQL): ___ SQL (PostgreSQL): ___ [note: range (inclusive end) in for loops in stored functions] SQL (SQLite): ___ Swift: ___ [note: range (exclusive end): ..<] [note: range (inclusive end): ...] UFL: SymCharDotDotDot [...][see also: Range.New/Array.SliceRestInfRangeDemo/OpSpreadCall/OpSpreadReceive] AutoHotkey: ___ C++: spread operator (receive only) C#: ___ Crystal: range (exclusive end) Excel: ___ Excel VBA: ___ Go: spread operator (call/receive) Java: spread operator (receive only) JavaScript: spread operator (call/receive) Kotlin: ___ PHP: spread operator (call/receive) Python: ___ R: spread operator (receive only) Ruby: range (exclusive end) Rust: ___ Scala: ___ SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: range (inclusive end), spread operator (receive only) UFL: SymCharLt [<][state if '<' doesn't support string comparison][see also: SymCharBracketsAngle/SymCharLtEqGt/OpLTStr] AutoHotkey: less-than, hotkey labels (for the left version of a modifier key) [note: doesn't support string comparison] C++: less-than C#: less-than [note: doesn't support string comparison] Crystal: less-than, subclass [note: supports chained comparisons] Excel: less-than Excel VBA: less-than Go: less-than Java: less-than [note: doesn't support string comparison] JavaScript: less-than Kotlin: less-than PHP: less-than Python: less-than [note: supports chained comparisons] R: less-than Ruby: less-than, subclass Rust: less-than Scala: less-than SQL (MySQL): less-than SQL (PostgreSQL): less-than SQL (SQLite): less-than Swift: less-than UFL: SymCharGt [>][state if '>' doesn't support string comparison][see also: SymCharBracketsAngle/SymCharLtEqGt/OpGTStr] AutoHotkey: greater-than, hotkey labels (for the right version of a modifier key) [note: doesn't support string comparison] C++: greater-than C#: greater-than [note: doesn't support string comparison] Crystal: greater-than [note: supports chained comparisons] Excel: greater-than Excel VBA: greater-than Go: greater-than Java: greater-than [note: doesn't support string comparison] JavaScript: greater-than [note (CSS): child combinator (find a direct child)] [note (CSS): space is descendant combinator (find a descendant)] Kotlin: greater-than PHP: greater-than Python: greater-than [note: supports chained comparisons] R: greater-than Ruby: greater-than Rust: greater-than Scala: greater-than SQL (MySQL): greater-than SQL (PostgreSQL): greater-than SQL (SQLite): greater-than Swift: greater-than UFL: SymCharLtLt [<<][see also: BitShiftLeft] AutoHotkey: bitshift left C++: bitshift left, insertion operator (e.g. std::cout << "abc") C#: bitshift left Crystal: bitshift left, array push, string append Excel: ___ [can use: BITLSHIFT] [version: Excel 2013: BITLSHIFT()] Excel VBA: ___ [can use: WorksheetFunction.Bitlshift] [version: Excel 2013: BITLSHIFT()] Go: bitshift left Java: bitshift left JavaScript: bitshift left Kotlin: ___ [can use: shl] PHP: bitshift left Python: bitshift left R: ___ [can use: bitwShiftL] Ruby: bitshift left, array push, string append Rust: bitshift left Scala: bitshift left SQL (MySQL): bitshift left SQL (PostgreSQL): bitshift left, strictly left of (geometric types), strictly contained by (network address types) SQL (SQLite): bitshift left Swift: bitshift left UFL: SymCharGtGt [>>][see also: BitShiftRight] AutoHotkey: bitshift right C++: bitshift right, extraction operator (e.g. std::cin >> myvar) C#: bitshift right Crystal: bitshift right Excel: ___ [can use: BITRSHIFT] [version: Excel 2013: BITRSHIFT()] Excel VBA: ___ [can use: WorksheetFunction.Bitrshift] [version: Excel 2013: BITRSHIFT()] Go: bitshift right Java: bitshift right JavaScript: bitshift right Kotlin: ___ [can use: shr] PHP: bitshift right Python: bitshift right R: ___ Ruby: bitshift right Rust: bitshift right Scala: bitshift right SQL (MySQL): bitshift right SQL (PostgreSQL): bitshift right, strictly right of (geometric types), strictly contain (network address types) SQL (SQLite): bitshift right Swift: bitshift right UFL: SymCharGtGtGt [>>>][see also: BitShiftRightLogical] AutoHotkey: bitshift right logical C++: ___ C#: bitshift right logical Crystal: ___ Excel: ___ Excel VBA: ___ Go: ___ Java: bitshift right logical JavaScript: bitshift right logical [note: can't use >>> with BigInts] Kotlin: ___ [can use: ushr] [note: can't use ushr with unsigned integers] PHP: ___ Python: ___ [also: primary prompt (in interactive shell), '...' for secondary prompt] R: ___ [can use: bitwShiftR] [note: bitwShiftR appears to return unsigned, unless the shift is 0, which maintains the sign] Ruby: ___ Rust: ___ Scala: bitshift right logical SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: ___ UFL: SymCharLtEqGt [<=>][see also: NumCompare/StrCompare/SymCharLt/SymCharGt] AutoHotkey: ___ C++: compare (e.g. ints/strings) [e.g. int vCmp = (int)std::bit_cast<int8_t>(vNum1 <=> vNum2)] C#: ___ Crystal: compare (e.g. ints/strings) Excel: ___ Excel VBA: ___ Go: ___ Java: ___ JavaScript: ___ Kotlin: ___ PHP: compare (e.g. ints/strings) Python: ___ R: ___ Ruby: compare (e.g. ints/strings) Rust: ___ Scala: ___ SQL (MySQL): null-safe equal [note: NULL <=> NULL returns 1 (true), NULL = NULL returns NULL] SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: ___ UFL: SymCharMinusGt [->][e.g. thin-arrow function][see also: OpFuncAnon] AutoHotkey: ___ C++: member access [note: ptr->member is shorthand for (*ptr).member] C#: member access (in 'unsafe' code blocks) Crystal: anonymous functions Excel: ___ Excel VBA: ___ Go: ___ [note: <- is used for channel operations] Java: anonymous functions JavaScript: ___ Kotlin: anonymous functions, when expressions, types for higher-order functions PHP: member access Python: function return type (type annotation) (type hints) R: assignment operator [note: <- is more common] [note: <<- is the non-local assignment operator] Ruby: anonymous functions Rust: function (and anonymous function) return type and value Scala: map literal [note: <- is used in for loops] SQL (MySQL): get JSON value SQL (PostgreSQL): get JSON value SQL (SQLite): get JSON value Swift: function return type, anonymous functions UFL: SymCharEqGt [=>][e.g. fat-arrow function][see also: OpFuncAnon] AutoHotkey: anonymous functions C++: ___ C#: anonymous functions Crystal: map (hash) literal, map (hash) type (creating an empty hash) Excel: ___ Excel VBA: ___ Go: ___ Java: ___ JavaScript: anonymous functions Kotlin: ___ PHP: anonymous functions, map (array) literal, foreach, match expressions Python: ___ R: ___ Ruby: map (hash) literal Rust: macros, match expressions Scala: anonymous functions SQL (MySQL): ___ SQL (PostgreSQL): function call named parameters SQL (SQLite): ___ Swift: ___ UFL: SymCharCircumflex [^][see also: BitXor/OpPow] AutoHotkey: bitwise-xor, hotkey labels (for Ctrl) C++: bitwise-xor C#: bitwise-xor [also: ^Num returns an Index instance, e.g. to get the nth-to-last element] Crystal: bitwise-xor, set symmetric difference Excel: pow Excel VBA: pow [also: data type suffix: LongLong (^)] Go: bitwise-xor [note: ^vNum is bitwise-not (unary operator), vNum1 ^ vNum2 is bitwise-xor (binary operator)] Java: bitwise-xor JavaScript: bitwise-xor Kotlin: ___ [note: xor: use xor] PHP: bitwise-xor Python: bitwise-xor, set symmetric difference R: pow [also (pow): **] Ruby: bitwise-xor, set symmetric difference Rust: bitwise-xor, set symmetric difference Scala: bitwise-xor [note: '^' does not do set symmetric difference] SQL (MySQL): bitwise-xor SQL (PostgreSQL): pow [note: xor: use #] SQL (SQLite): ___ Swift: bitwise-xor UFL: SymCharColon [:][also: ':' is often using in date format and string format (e.g. sprintf) strings][see also: Range.New/Array.SliceRestInfRangeDemo/GotoDemo/ClassSubclass/OpTern] AutoHotkey: object properties, ternary operator, label (e.g. for goto) C++: ternary operator, label (e.g. for goto), subclass C#: function call named parameters, ternary operator, label (e.g. for goto), subclass, generic type constraints Crystal: function call named parameters, type annotation, struct properties, ternary operator, symbol (e.g. :mysymbol) Excel: cell range Excel VBA: statement separator, label (e.g. for GoTo) Go: map keys, slice/array slices, label (e.g. for goto) Java: object for loop, ternary operator, label JavaScript: object properties, ternary operator, label [note (CSS): pseudo-class: e.g. :active/:focus/:hover, :first-child/:nth-child(n), :root/:scope] Kotlin: type annotation (including function return value), subclass PHP: function call named parameters, ternary operator, label (e.g. for goto) Python: dictionary keys, line endings (e.g. function headers/for loops/if-statements), list slices, lambda functions, type hints R: range Ruby: function call named parameters, ternary operator, symbol (e.g. :mysymbol) Rust: struct properties, ('{:?}'/'{:#?}' are used with println!()), type annotations Scala: class properties, type annotation (type ascription) (including function return value) SQL (MySQL): label (stored procedures/stored functions) SQL (PostgreSQL): array slices SQL (SQLite): ___ [also: SQLite command-line shell: e.g. .parameter set :myvar 123] Swift: dictionary keys, function call named parameters, type annotation, ternary operator, label, subclass UFL: SymCharColonColon [::] AutoHotkey: hotkey labels, hotstring labels [e.g. press Shift+Ctrl+Win+Alt+Q to run the code underneath the hotkey label: +^#!q::] C++: scope resolution C#: scope resolution (namespace alias qualifier) Crystal: scope resolution Excel: ___ Excel VBA: ___ Go: ___ Java: method reference JavaScript: ___ [note (CSS): pseudo-element: e.g. ::first-letter, ::after] Kotlin: callable reference PHP: scope resolution [note: 'Scope Resolution Operator (also called Paamayim Nekudotayim)'] Python: ___ [note: in slicing, '[::-1]' to reverse strings/lists, is omitted start/end, and step -1, not a '::' operator] R: scope resolution [also: :::] Ruby: scope resolution Rust: scope resolution (path resolution) Scala: cons operator (for prepending) [note: ::: to prepend a list to a list] SQL (MySQL): ___ SQL (PostgreSQL): type casting SQL (SQLite): ___ Swift: ___ UFL: SymCharBracketsRound [or SymCharRoundBrackets/SymCharParens/SymCharParentheses][()][round brackets (parentheses)][note: parentheses are also used for: order of operations/precedence, if-statements/while loops/for loops, function definitions/calls][note: IfKeywords section states whether if-statements require parentheses][see also: IfKeywords] AutoHotkey: ___ [note: AHK v2: if a line contains a function call only, with no return value, parentheses can be omitted] C++: type casting C#: type casting, tuple literal Crystal: map types [note: parentheses are often optional for function calls] Excel: ___ Excel VBA: array indexing [note: array indexing is done via square brackets in most languages] Go: ___ Java: type casting JavaScript: ___ Kotlin: ___ PHP: type casting Python: tuple literal, generator expression R: ___ Ruby: ___ [note: parentheses are often optional for function calls] Rust: tuple literal, unit type Scala: array/map indexing, tuple literal, unit type [note: array indexing is done via square brackets in most languages] SQL (MySQL): enclose subqueries, list for IN operator SQL (PostgreSQL): enclose subqueries, list for IN operator, record SQL (SQLite): enclose subqueries, list for IN operator Swift: tuple literal, unit type UFL: SymCharBracketsSquare [or SymCharSquareBrackets][[]][square brackets][note: square brackets are often used to create array literals][see also: Array.SliceTo/Array.SliceRestInfRangeDemo/Array.NewEmptyIntDemo/Array.OverwriteIntDemo] AutoHotkey: array/map indexing [also: optional params in the documentation] C++: array/map indexing, array types (in array declarations) C#: array/dictionary indexing, string/array slicing, array types, attributes (metadata above classes/methods) Crystal: array/map indexing, string/array slicing Excel: structured references (e.g. refer to ranges/external workbooks) Excel VBA: shorthand to refer to ranges, member access [e.g. shorthand: [A1].Value = 123] Go: array/map indexing, string/array slicing, array/map types Java: array indexing, array types JavaScript: array/object indexing Kotlin: array/map indexing PHP: array/array-as-map indexing, array-as-map literal [also: array push: $oArray[] = $vValue] Python: array/dictionary indexing, string/list slicing R: vector/vector-as-map/object indexing, vector slicing Ruby: array/map/object indexing, string/list slicing Rust: array/map indexing, string/list slicing, array types Scala: array/map types SQL (MySQL): ___ SQL (PostgreSQL): array indexing, create array (ARRAY[]), array types SQL (SQLite): GLOB character class, identifiers [note: identifiers can be created using double quotes/square brackets/backticks/unquoted] Swift: array/dictionary indexing, dictionary literal, string/list slicing UFL: SymCharBracketsCurly [or SymCharCurlyBrackets/SymCharCurlyBraces][{}][curly brackets (curly braces)][note: code blocks are used for: e.g. if-statements, loops, functions, classes/methods][see also: IfKeywords/VarReDeclSetDemo/SymInterpolateVarDemo] AutoHotkey: object literal, code blocks C++: array/map/struct literal, code blocks C#: array/dictionary/anonymous type literal, code blocks [note: square brackets also work for array literals] Crystal: map (hash) literal, procs/blocks (trailing blocks) [WARNING: {} *NOT* used for code blocks] Excel: array constants [note: no code blocks] Excel VBA: ___ [WARNING: {} *NOT* used for code blocks] Go: array/map/struct literal, code blocks Java: array literal, class definitions for custom simple objects, code blocks JavaScript: object literal, code blocks Kotlin: data class, code blocks, (single) trailing lambdas PHP: code blocks Python: dictionary/set literal [WARNING: {} *NOT* used for code blocks] R: code blocks Ruby: map (hash) literal, procs/blocks (trailing blocks) [WARNING: {} *NOT* used for code blocks] Rust: struct literal, code blocks Scala: code blocks, (single) trailing closures SQL (MySQL): ___ [WARNING: {} *NOT* used for code blocks] SQL (PostgreSQL): array literals [WARNING: {} *NOT* used for code blocks] SQL (SQLite): ___ [WARNING: {} *NOT* used for code blocks] Swift: struct literal, code blocks, (multiple) trailing closures UFL: SymCharBracketsAngle [or SymCharAngleBrackets][<>][angle brackets][see also: SymCharBracketsAngle] AutoHotkey: '#Include <LibName>' C++: map types, '#include <filename>' C#: dictionary types, '#include <filename>' Crystal: ___ [note: Go uses round brackets for types] [also: percent literals work with square/curly/angle brackets] Excel: ___ Excel VBA: ___ Go: ___ [note: Go uses square brackets for types] Java: map types JavaScript: ___ Kotlin: array/map types PHP: ___ [also: <?php ... ?> tags] [note: PHPDoc annotations use angle brackets for types] Python: ___ [note: Python uses square brackets for type hints] R: ___ Ruby: ___ [also: percent literals work with square/curly/angle brackets] Rust: map types, lifetime annotations [note: turbofish operator: ::<> (specify a type, e.g. '::<i32>'/'::<String>')] Scala: ___ [note: Scala uses square brackets for types] SQL (MySQL): ___ [also: placeholders in the documentation] SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: dictionary types UFL: SymCharExcl [!][exclamation mark (exclamation point)][see also: OpNot/OpNotIntDemo/OpNotStrDemo] AutoHotkey: logical NOT, hotkey labels (for Alt) C++: logical NOT C#: logical NOT Crystal: logical NOT [note: ! performs array operations in-place, without '!': returns a new array, e.g. flatten/reverse/shuffle/sort/uniq] Excel: sheet reference (e.g. 'Sheet1!A1') Excel VBA: ___ [also: data type suffix: Single (!)] Go: logical NOT Java: logical NOT JavaScript: logical NOT Kotlin: logical NOT [also: !in, !is] [also (!!): force unwrap] PHP: logical NOT Python: ___ R: logical NOT Ruby: logical NOT [note: ! performs array operations in-place, without '!': returns a new array, e.g. flatten/reverse/shuffle/sort/uniq] Rust: logical NOT/bitwise NOT, macro invocation (e.g. println!()) [WARNING: Rust's ! is logical not (for bools) and bitwise not (for ints)] Scala: logical NOT SQL (MySQL): logical NOT (also: NOT) SQL (PostgreSQL): ___ [deprecated: factorial: n!, !!n] SQL (SQLite): ___ Swift: logical NOT, force unwrap (unwrap an optional), implicitly unwrapped optionals (type names with '!') UFL: SymCharQuote [or SymCharDQ]["][double quotes][see also: SymStringLiteral/StrMultiLineDemo] AutoHotkey: string literal (also: ') [note ('): AHK v2 onwards] C++: string literal C#: string literal [also: multi-line: """] Crystal: string literal Excel: string literal Excel VBA: string literal Go: string literal Java: string literal [also: multi-line: """] JavaScript: string literal (also: ') [note (JSON): string literals: require double quotes] [note (HTML): attribute values: can use double quotes/single quotes/neither (style guides often recommend double quotes)] Kotlin: string literal [also: multi-line: """] PHP: string literal (also: ') [WARNING: " allows interpolation, ' doesn't] Python: string literal (also: ') [also: multi-line: """] R: string literal (also: ') Ruby: string literal (also: ') [WARNING: " allows interpolation, ' doesn't] Rust: string literal Scala: string literal [also: multi-line: """] SQL (MySQL): string literal (also: ') [note: ` is used for identifiers (e.g. column names)] [note: ANSI_QUOTES mode treats items in quotes as identifiers, not string literals] SQL (PostgreSQL): identifier [WARNING: double quotes are used for identifiers (e.g. column names)] SQL (SQLite): identifiers [WARNING: double quotes are used for column names] [note: identifiers can be created using double quotes/square brackets/backticks/unquoted] [note: fallback: if an identifier isn't found, a string literal is assumed] Swift: string literal [also: multi-line: """] UFL: SymCharHash [#][see also: SymComment] AutoHotkey: directives (e.g. #Include), hotkey labels (for Win) C++: preprocessor directives (e.g. #include), macro stringification [also (##): macro concatenation] C#: directives (e.g. #if) Crystal: single-line comments, string interpolation [WARNING: # is a special character in string literals] Excel: error code prefix, spill range [version: Excel 2021: spill range] Excel VBA: directives (e.g. #If), date literals (e.g. '#5/4/2006#', uses US date order irrespective of locale, note: '#4-May-2006#'/'#May-4-2006#' autocorrect to the numeric form) [also: data type suffix: Double (#)] Go: ___ Java: ___ JavaScript: private class fields Kotlin: ___ PHP: single-line comments, attributes (metadata annotations) [also: //] Python: single-line comments R: single-line comments Ruby: single-line comments, string interpolation [WARNING: # is a special character in string literals] Rust: attributes (metadata annotations) [also: {:#?} is used with println!()] Scala: type projection (e.g. 'Outer#Inner') SQL (MySQL): comments [also: --] SQL (PostgreSQL): bitwise-xor, geometric type operators (e.g. point count, intersection point) SQL (SQLite): ___ Swift: directives (e.g. #if), freestanding macros (including 'special literals') UFL: SymCharDollar [$][dollar sign] AutoHotkey: hotkey labels (prevent hotkey being triggered by key presses sent by AutoHotkey) C++: ___ C#: string interpolation Crystal: global variable prefix Excel: absolute cell reference (e.g. '$A$1') Excel VBA: ___ [note: some built-in functions have 2 versions, with/without '$', e.g. Left/Left$, the '$' version may be more performant, and may have different error handling] [also: data type suffix: String ($)] Go: ___ Java: ___ JavaScript: string interpolation Kotlin: string interpolation [WARNING: $ is a special character in string literals] PHP: variable name prefix, string interpolation [WARNING: $ is a special character in string literals] Python: ___ R: member access Ruby: global variable prefix Rust: macro variable names (often preceding fragment specifiers) Scala: string interpolation SQL (MySQL): ___ SQL (PostgreSQL): dollar quoting (raw strings, to avoid escaping chars, e.g. $$mystring$$, $mytag$mystring$mytag$) SQL (SQLite): ___ [also: SQLite command-line shell: e.g. .parameter set $myvar 123] Swift: closure argument shorthand (e.g. $0, $1) UFL: SymCharAmpersand [&][see also: BitAnd] AutoHotkey: bitwise-and, pass by reference(/create a reference), hotkey labels (multiple keys) [deprecated: address-of] C++: bitwise-and, address-of, by reference C#: bitwise-and Crystal: bitwise-and, set intersection, capture/pass a proc/block, short one-parameter syntax (e.g. '&.myname', equivalent to Ruby's symbol-to-proc) [also: prefixes mathematical operators (e.g. &+) to allow overflowing without errors] Excel: string concatenation Excel VBA: string concatenation [also: data type suffix: Long (&)] [also: octal/hex prefixes: &O/&H] Go: bitwise-and, address-of (memory address) Java: bitwise-and JavaScript: bitwise-and Kotlin: ___ PHP: bitwise-and, pass by reference Python: bitwise-and, set intersection R: logical AND Ruby: bitwise-and, set intersection, capture/pass a block, symbol-to-proc (e.g. '&:myname', '&' applied to a symbol) Rust: bitwise-and, referencing (borrowing), set intersection, address-of Scala: bitwise-and, set intersection SQL (MySQL): bitwise-and SQL (PostgreSQL): bitwise-and SQL (SQLite): bitwise-and Swift: bitwise-and UFL: SymCharAmpersandAmpersand [&&][see also: OpAnd] AutoHotkey: logical AND C++: logical AND C#: logical AND Crystal: logical AND Excel: ___ Excel VBA: ___ Go: logical AND Java: logical AND JavaScript: logical AND Kotlin: logical AND PHP: logical AND Python: ___ R: logical AND [WARNING: && works on the first vector element, & works on all vector elements] Ruby: logical AND Rust: logical AND Scala: logical AND SQL (MySQL): logical AND SQL (PostgreSQL): overlap operator SQL (SQLite): ___ Swift: logical AND UFL: SymCharAsterisk [*][see also: Mul/OpSpreadCall/OpSpreadReceive] AutoHotkey: multiply, spread operator receive/call [deprecated: dereference] C++: multiply, dereferencing (indirection), pointer declaration C#: multiply, dereferencing, pointer declaration [note: pointer manipulation requires an 'unsafe' block] Crystal: multiply, spread operator receive/call Excel: multiply Excel VBA: multiply Go: multiply, dereferencing, pointer declaration Java: multiply JavaScript: multiply Kotlin: multiply, spread operator call PHP: multiply Python: multiply, spread operator receive/call, repeat string [Python: WARNING: repeat string] R: multiply Ruby: multiply, spread operator receive/call Rust: multiply, dereferencing, pointer declaration [note: pointer manipulation requires an 'unsafe' block] Scala: multiply, spread operator receive/call SQL (MySQL): multiply, SELECT all columns SQL (PostgreSQL): multiply, SELECT all columns SQL (SQLite): multiply, SELECT all columns, GLOB (matches 0 or more chars) Swift: multiply UFL: SymCharAsteriskAsterisk [**][see also: OpPow] AutoHotkey: pow C++: ___ [also: pointer to a pointer] C#: ___ Crystal: pow, explode/capture named arguments (into a NamedTuple) Excel: ___ Excel VBA: ___ Go: ___ [also: pointer to a pointer] Java: ___ JavaScript: pow Kotlin: ___ PHP: pow Python: pow, explode/capture named arguments (keyword arguments: kwargs), merge collections R: pow Ruby: pow, explode/capture named arguments, merge collections Rust: ___ [also: pointer to a pointer] Scala: ___ SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: ___ UFL: SymCharPlus [or SymCharAdd][+][see also: Add/UnaryAdd/OpConcat/BoolToInt] AutoHotkey: addition, hotkey labels (for Shift) C++: addition, string concatenation [WARNING: + for addition and concatenation] C#: addition, string concatenation [WARNING: + for addition and concatenation] Crystal: addition, string/array concatenation, set merging [WARNING: + for addition and concatenation] Excel: addition Excel VBA: addition, string concatenation (also: &) [WARNING: + for addition and concatenation] Go: addition, string concatenation [WARNING: + for addition and concatenation] Java: addition, string concatenation [WARNING: + for addition and concatenation] JavaScript: addition, string concatenation [WARNING: + for addition and concatenation] Kotlin: addition, string/array concatenation, set/map merging [WARNING: + for addition and concatenation] PHP: addition, array merging (i.e. map merging) Python: addition, string/list/tuple concatenation [WARNING: + for addition and concatenation] R: addition Ruby: addition, string/array concatenation, set merging [WARNING: + for addition and concatenation] Rust: addition, string concatenation [WARNING: + for addition and concatenation] Scala: addition, string concatenation, set add element, map add key-value pair [WARNING: + for addition and concatenation] [also (:+): array append element] [also (+:): array prepend element] SQL (MySQL): addition SQL (PostgreSQL): addition SQL (SQLite): addition Swift: addition, string/array concatenation [WARNING: + for addition and concatenation] UFL: SymCharPlusPlus [or SymCharAddAdd][++][see also: OpInc] AutoHotkey: increment [e.g. i++ ++i] C++: increment [e.g. i++ ++i] C#: increment [e.g. i++ ++i] Crystal: ___ Excel: ___ Excel VBA: ___ Go: increment [e.g. i++] Java: increment [e.g. i++ ++i] JavaScript: increment [e.g. i++ ++i] Kotlin: increment [e.g. i++ ++i] PHP: increment [e.g. $i++ ++$i] Python: ___ R: ___ Ruby: ___ Rust: ___ Scala: array concatenation, set/map merging SQL (MySQL): ___ SQL (PostgreSQL): ___ SQL (SQLite): ___ Swift: ___ [deprecated (removed in v3.0): i++ ++i] UFL: SymCharComma [,][note: ',' is often used as a thousands separator (in some locales '.' is used)][also: argument separator (e.g. functions, arrays)][see also: VarDeclMult/VarDeclSetMult/VarSetMult/VarDeleteMult/Swap/Map.NewStrDemo/Object.NewStrDemo/Array.TrailingComma] AutoHotkey: argument separator, statement separator [deprecated: AHK v1: comma after command name (e.g. 'MyCommand, Arg1, Arg2' was allowed, now only 'MyCommand Arg1, Arg2' is allowed)] [note: deprecated: AHK v1: 'myvar := (Arg1, Arg2, Arg3)' used to return Arg1, it now returns Arg3] [deprecated: AHK v1: commas required escaping in commands (unless force expression used)] C++: argument separator C#: argument separator Crystal: argument separator Excel: argument separator Excel VBA: argument separator Go: argument separator Java: argument separator JavaScript: argument separator Kotlin: argument separator PHP: argument separator Python: argument separator [MAJOR WARNING: creates a tuple: oTuple = "a", 1] R: argument separator Ruby: argument separator [MAJOR WARNING: creates an array: oArray = "a", 1] Rust: argument separator Scala: argument separator SQL (MySQL): argument separator SQL (PostgreSQL): argument separator SQL (SQLite): argument separator Swift: argument separator UFL: SymCharMinus [or SymCharHyphen/SymCharSub][-][note: kebab-case][see also: Sub/UnarySub] AutoHotkey: subtract C++: subtract C#: subtract Crystal: subtract, set difference Excel: subtract Excel VBA: subtract Go: subtract Java: subtract JavaScript: subtract [note (HTML): hyphens are valid in class names] Kotlin: subtract, set difference PHP: subtract Python: subtract, set difference R: subtract Ruby: subtract, set difference Rust: subtract, set difference Scala: subtract SQL (MySQL): subtract SQL (PostgreSQL): subtract SQL (SQLite): subtract Swift: subtract UFL: SymCharMinusMinus [or SymCharHyphenHyphen/SymCharSubSub][--][see also: OpDec/OpSubSubOrDecDemo/SymComment] AutoHotkey: decrement [e.g. i-- --i] C++: decrement [e.g. i-- --i] C#: decrement [e.g. i-- --i] Crystal: ___ Excel: ___ Excel VBA: ___ Go: decrement [e.g. i--] Java: decrement [e.g. i-- --i] JavaScript: decrement [e.g. i-- --i] [note (CSS): custom properties ('CSS variables')] Kotlin: decrement [e.g. i-- --i] PHP: decrement [e.g. $i-- --$i] Python: ___ R: ___ Ruby: ___ Rust: ___ Scala: set difference SQL (MySQL): comment [note: -- must be followed by space/tab/linefeed etc] [also: #] SQL (PostgreSQL): comment SQL (SQLite): comment Swift: ___ [deprecated (removed in v3.0): i-- --i] UFL: SymCharSemicolon [;][see also: SymSep/SymEnd] AutoHotkey: single-line comment C++: statement separator, for loops [note: statements must end with ;] C#: statement separator, for loops [note: statements must end with ;] Crystal: statement separator Excel: ___ [note: in some locales, ';' is used as the list separator (function param separator), because ',' is unavailable when it is used as the decimal separator] Excel VBA: Debug.Print (print without line break) Go: statement separator, for loops [note: the Go Playground auto-formats these away (replacing multi-statement one-liners with multiple lines)] Java: statement separator, for loops [note: statements must end with ;] JavaScript: statement separator, for loops [note: it is common to end lines with ;] Kotlin: statement separator PHP: statement separator, for loops [note: statements must end with ;] Python: statement separator R: statement separator Ruby: statement separator Rust: statement separator, array types [note: statements must end with ; (except the last)] Scala: statement separator SQL (MySQL): statement separator [note: statements must end with ; (except the last)] SQL (PostgreSQL): statement separator [note: statements must end with ; (except the last)] SQL (SQLite): statement separator [note: statements must end with ; (except the last)] Swift: statement separator UFL: SymCharQuest [or SymCharQM][?][question mark][see also: OpTern/OpNullCoalescing/OpSafeNav] AutoHotkey: ternary operator, maybe operator (allow passing/receiving unset variables) C++: ternary operator C#: ternary operator, nullable types Crystal: ternary operator, nilable types (nullable types), predicate methods (return a bool) Excel: ___ Excel VBA: shorthand for Print in the Immediate Window [also: Single data type] Go: ___ Java: ternary operator JavaScript: ternary operator Kotlin: nullable types PHP: ternary operator, nullable types [also: <?php ... ?> tags] Python: ___ R: ___ Ruby: ternary operator, predicate methods (return a bool) Rust: error propagation (unwrap or return early: unwrap if 'Ok', else return 'Err') [also: '{:?}'/'{:#?}' are used with println!()] Scala: any type [deprecated: _ (any type)] [note: '?' is sometimes used in custom predicate method names] SQL (MySQL): ___ SQL (PostgreSQL): JSONB (but not JSON, check for item existence) SQL (SQLite): GLOB (matches 1 char) Swift: ternary operator, optional types (nullable types) UFL: SymCharAt [@][note: often used in email addresses] AutoHotkey: ___ [note: Ahk2Exe uses '@' for directives] C++: ___ C#: verbatim string literals, non-standard variable names/identifiers Crystal: private instance fields [also (@@): private class fields] Excel: structured references, implicit intersection operator [version: Excel 2010: structured references] [version: Excel 2019: implicit intersection operator] Excel VBA: ___ [also: data type suffix: Currency (@)] Go: ___ Java: annotations (e.g. @FunctionalInterface, @SuppressWarnings) JavaScript: ___ Kotlin: annotations, jump labels PHP: error control operator (suppresses errors) Python: decorators (e.g. @classmethod, @property, @myprop.setter), matrix multiplication operator R: member access (slots for S4 classes) Ruby: private instance fields [also (@@): private class fields] Rust: ___ Scala: annotations SQL (MySQL): custom variables [also (@@): system variables (built-in variables)] SQL (PostgreSQL): ___ [note: '@' appears in various operators for geometric types] SQL (SQLite): ___ [also: SQLite command-line shell: e.g. .parameter set @myvar 123] Swift: attributes (e.g. @dynamicCallable), attached macros UFL: SymCharBackslash [\][note: / and \ are used as dir separators in file paths][see also: SymEscape/StrMultiLineDemo] AutoHotkey: ___ C++: string escape character, multi-line strings/line continuation C#: string escape character Crystal: string escape character, multi-line strings/line continuation Excel: custom text format escape character (make characters literal) Excel VBA: truncated division Go: string escape character Java: string escape character JavaScript: string escape character, multi-line strings Kotlin: string escape character PHP: string escape character Python: string escape character, multi-line strings/line continuation R: string escape character, anonymous function Ruby: string escape character, multi-line strings/line continuation Rust: string escape character, multi-line strings Scala: string escape character SQL (MySQL): string escape character SQL (PostgreSQL): string escape character SQL (SQLite): ___ Swift: string escape character, string interpolation UFL: SymCharUnderscore [_][note: snake_case][also: often used for a variable that needs a name but isn't used, e.g. in a loop/function block][also: sometimes used as a prefix for an object property name intended to be private][see also: SymSepNum/VarDeclSetMultDiscard/VarSetMultDiscard] AutoHotkey: convention to prefix private fields with '_' [note (__): built-in methods for custom classes typically start with double underscore, e.g. __Get/__Set] C++: ___ C#: digit separator Crystal: digit separator Excel: ___ Excel VBA: line continuation Go: digit separator, discard values [note: unused variables: 'assigning the unused variable ... to the blank identifier will silence the unused variable error'] Java: digit separator [WARNING: '_' can't be used as a variable name (since Java 9)] JavaScript: digit separator Kotlin: digit separator PHP: digit separator [note (__): methods beginning with double underscore are called magic methods] Python: digit separator, switch statement default case, convention to prefix private fields with '_' [note (__): 'dunder' refers to methods that start and end with double underscore (e.g. __init__)] [also: IDLE: '_' stores the result of the last expression evaluated] R: ___ [WARNING: variable names can't start with '_' (unless backticks are used)] Ruby: digit separator Rust: digit separator, switch statement default case [note: unused variables: 'To silence the warning for the individual variable, prefix it with an underscore such as _x.'] Scala: digit separator, switch statement default case, param in blocks, assign default value for type [deprecated: _ (any type)] SQL (MySQL): LIKE (matches 1 char) SQL (PostgreSQL): digit separator, LIKE (matches 1 char) SQL (SQLite): digit separator, LIKE (matches 1 char) Swift: digit separator, omit argument label (Swift function params have 2 'names': argument label, used externally when calling the function (unless '_' is used), and parameter name, used internally) UFL: SymCharGrave [or SymCharBacktick][`] AutoHotkey: escape character (most languages use '\') C++: ___ C#: types Crystal: shell command execution Excel: ___ Excel VBA: ___ Go: struct tags, raw string literals Java: ___ JavaScript: template literals (e.g. multi-line strings, string interpolation) Kotlin: non-standard variable names/identifiers PHP: shell command execution Python: ___ [deprecated: shorthand for repr() function, to inspect variables] R: non-standard variable names, `if`(), sapply() with `[[` [note: `if` lets you call the 'if' control flow statement directly] [note: `[[` gives you a function, which you can use to extract items] Ruby: shell command execution Rust: ___ Scala: non-standard variable names/identifiers (e.g. use a keyword as a method name: `with`) SQL (MySQL): identifiers (e.g. column names) SQL (PostgreSQL): ___ SQL (SQLite): identifiers [note: identifiers can be created using double quotes/square brackets/backticks/unquoted] Swift: non-standard variable names/identifiers UFL: SymCharPipe [|][see also: BitOr/OpPrecBitOrEqualsDemo/Set.Union] AutoHotkey: bitwise-or C++: bitwise-or C#: bitwise-or Crystal: bitwise-or, block arguments, 'do' keyword, array-as-set/set merging, union types Excel: ___ Excel VBA: ___ Go: bitwise-or, union types Java: bitwise-or JavaScript: bitwise-or Kotlin: default margin prefix in multi-line raw strings PHP: bitwise-or, union types Python: bitwise-or, dictionary/set merging, union types R: logical OR Ruby: bitwise-or, block arguments, array-as-set/set merging Rust: bitwise-or, block arguments, set merging, pattern matching Scala: bitwise-or, set merging, union types SQL (MySQL): bitwise-or SQL (PostgreSQL): bitwise-or SQL (SQLite): bitwise-or Swift: bitwise-or UFL: SymCharPipePipe [||][see also: OpOr/OpOrIntDemo/OpConcat] AutoHotkey: logical OR C++: logical OR C#: logical OR Crystal: logical OR Excel: ___ Excel VBA: ___ Go: logical OR Java: logical OR JavaScript: logical OR Kotlin: logical OR PHP: logical OR Python: ___ R: logical OR [WARNING: || works on the first vector element, | works on all vector elements] Ruby: logical OR Rust: logical OR Scala: logical OR SQL (MySQL): logical OR [WARNING: || does concatenation if use 'set sql_mode=PIPES_AS_CONCAT'] SQL (PostgreSQL): concatenation SQL (SQLite): concatenation Swift: logical OR UFL: SymCharTilde [~][see also: BitNot] AutoHotkey: bitwise-not, hotkey labels (allow key press to pass through, don't consume key press) C++: bitwise-not, class destructors C#: bitwise-not, class destructors Crystal: bitwise-not Excel: escape character for * ? ~ wildcards Excel VBA: ___ Go: generics ('~T is the set of all types whose underlying type is T') Java: bitwise-not JavaScript: bitwise-not [note (CSS): general sibling combinator (subsequent-sibling combinator) (find matching 'younger' siblings)] Kotlin: ___ PHP: bitwise-not Python: bitwise-not R: model formula ('Tilde is used to separate the left- and right-hand sides in a model formula') Ruby: bitwise-not Rust: ___ [deprecated: bitwise-not] Scala: bitwise-not SQL (MySQL): bitwise-not SQL (PostgreSQL): bitwise-not SQL (SQLite): bitwise-not Swift: bitwise-not
In mathematics, and programming, calculations do not simply occur from left-to-right, you have to consider the relative precedences of the operators. E.g. 1 + 2 - 3 * 4 / 5 This is equivalent to: (1 + 2) - ((3 * 4) / 5) = 0.6 I.e. * and / have a higher precedence than + and -. This is called order of operations, and common mnemonics for operator precedence are BODMAS and PEMDAS, to help you remember which operators have the higher precedence. Programming languages typically have an operator precedence table. Various such tables are listed on this website, here: Documentation Links. In programming it is generally wise not to rely 100% on the documentation, but to perform your own tests, to confirm that the documentation is in fact correct. The documentation may be incorrect or out-of-date, or there may be a bug in the programming language. There may even be a bug in the microchip, causing errors in calculations. What follows are some lines of code for testing operator precedence. In each test, the pseudocode returns true if the programming language uses the more common operator precedence. * is of higher precedence than binary + Pseudocode: vRetMulAdd = (2 * 3 + 4) == 10 To confirm the precedence of two operators, you want a formula/expression, that would have two different possible answers, depending on which operator has precedence. E.g. 2 * 3 + 4. If + was of higher precedence, the answer would be 2 * (3 + 4) = 14. If * was of higher precedence, the answer would be (2 * 3) + 4 = 10. The answer is 10, so * has higher precedence. ** is of higher precedence than unary - Pseudocode: vRetPowUnAdd = (- 3 ** 2) == -9 See the section 'OpPrecPowUnarySubDemo' above, which compares the results for various programming languages. Many programming languages lack a power operator, the tests below however, should be applicable to virtually all programming languages. % is of higher precedence than binary + Pseudocode: vRetModAdd = (10 % 5 + 2) == 2 && is of higher precedence than || Pseudocode: vRetAndOr1 = (false && false || true) == true vRetAndOr2 = (false && true || true) == true Note: '2 choose 3' with repetitions, gives 8 permutations: FFF, FFT, FTF, FTT, TFF, TFT, TTF, TTT. Listed above are the 2 out of 8 permutations that give distinct answers. I.e. the tests differ, but both serve the same purpose, to confirm that && has a higher precedence than ||. Note: C++ debuggers may give a warning for this particular example, suggesting that the user add parentheses for clarity/safety. == is of higher precedence than || Pseudocode: vRetEqOr1 = (false == false || true) == true vRetEqOr2 = (false == true || true) == true Listed above are the 2 out of 8 permutations that give distinct answers. == is of higher precedence than && Pseudocode: vRetEqAnd1 = (false == false && false) == false vRetEqAnd2 = (false == true && false) == false Listed above are the 2 out of 8 permutations that give distinct answers. << is of higher precedence than | Pseudocode: vRetBitShiftBitOr = (1 << 8 | 2) == 258 | is of higher precedence than == Pseudocode: vRetBitOrEq = (2 | 1 == 3) == true This relates to an oddity in C, and various languages that derive from it (e.g. C++/C#/Java/JavaScript/PHP/Scala). In C: 2 | 1 == 3 is equivalent to: 2 | (1 == 3) rather than the likely more reasonable/useful: (2 | 1) == 3 The same applies to & and ^. The operator precedence table for C has the full list. Note: '2 | (1 == 3)' is impossible in many languages because they disallow 'int | bool'. See the section 'OpPrecBitOrEqualsDemo' above, which compares the results for various programming languages. Author's view: most of the time C gets it right, it had the best syntax of any programming language in its day, and has been probably the number one source of/influence for good syntax in programming languages. && is of higher precedence than = Pseudocode: vTemp = true && false vRetAssignAnd = vTemp == false This relates to an oddity in Ruby. '&&' and 'and' are both operators, and most of the time equivalent. As is common in most programming languages, && has higher precedence than =, however, = has higher precedence than 'and'. So, 'vTemp = true && false' is equivalent to 'vTemp = (true && false)'. But, 'vTemp = true and false' is equivalent to '(vTemp = true) and false'. Common operator precedences Some common precedences, from highest to lowest, representative of many but not all programming languages: Starting with the C operator precedence table, with additions/differences noted. Operator precedence table: :: (scope resolution) [C++] ++ -- (suffix) [C] () (function call) [C] [] (array subscript) [C] . (member access) [C] [] (array subscript) [JavaScript] new (with arguments) [JavaScript] () (function call) [JavaScript] new (without arguments) [JavaScript] -> (member access) [C] ++ -- (suffix) [JavaScript] ++ -- (prefix) [C] + - (unary) [C] ! ~ [C] (type) [C] * (indirection) [C] & (address-of) [C] sizeof [C] new [C] ** [JavaScript] * / % [C] + - (binary) [C] << >> [C] << >> >>> [JavaScript] & [Python/Ruby] ^ [Python/Ruby] | [Python/Ruby] <=> [C++] < <= > >= [C] == != [C] === !== [JavaScript] & [C/C++/C#/JavaScript/PHP] ^ [C/C++/C#/JavaScript/PHP] | [C/C++/C#/JavaScript/PHP] && [C] || [C] ?? [JavaScript] ? : [C] throw [C++] = [C] += -= [C] *= /= %= [C] <<= >>= [C] &= ^= |= [C] ? : [JavaScript] => [JavaScript] ... [JavaScript] , [C]
role: common operators in many languages: + [add][sometimes concatenate] - [subtract] * [multiply][sometimes dereference (indirection), sometimes splat/spread][Python: WARNING: repeat string] / [divide] ** [power][note: not in C++][sometimes double splat] see below: ~ & | ^ [bitwise: not/and/or/xor] see below: ! && || [logical: not/and/or] ~ [bitwise not][C++/C#: ~ is used for class destructors] & [bitwise and][Visual Basic: & is concatenate][C++: & is also address-of] | [bitwise or] ^ [bitwise xor][^ is sometimes power] ! [logical not (logical negation)][Swift: unwrap optional][Rust: WARNING: ! is also bitwise-not (and used for macro expansion)][Crystal/Ruby: ! performs array operations in-place, without '!': returns a new array, e.g. flatten/reverse/shuffle/sort/uniq] && [logical and] || [logical or] ? : [ternary operator] << >> >>> [bitshift: left/right (signed)/right (logical/unsigned/zero-fill)][C++: << and >> can mean output/input] == [equals] != <> [not equal (inequality)] < > [less than/greater than][sometimes used as angle brackets (e.g. HTML)][Python: comparison operators can be chained e.g. x < y < z] <= >= [less than or equal to/greater than or equal to] % [modulo (modulus)][Excel: % is equivalent to '/100'][Ruby: % also performs sprintf] role: assignment operators: = [assign][can be used for function parameter default values] := [assign][walrus operator][can be used for function parameter default values] ++ [increment] -- [decrement][SQL: single-line comments] role: operators (augmented assignment versions): += -= *= /= **= &= |= ^= >>= <<= >>>= .= %= ??= //= ~/= \= role: operators further: ~/ [C-style (truncated) integer division (e.g. Dart)][corkscrew operator (author's name proposal)] // [floor division (e.g. Python)][often a comment symbol] %% [floormod (floor modulo) (e.g. R)] role: operators further: <=> [comparison][spaceship operator][e.g. C++/Perl/PHP/Ruby] !== [not equal (type safe)] === [equals (type safe)] => [AutoHotkey/C#/JavaScript/PHP/Scala: fat-arrow function][PHP: key-value pair definitions] -> [C++: member access (structure pointer operator)][Java/Kotlin: arrow function (lambda expression)][Kotlin: declaring function types][PHP: property access][SQL: get JSON subcomponent (raw as string/raw)] ->> [SQL: get JSON subcomponent (as JSON object/JSON string)] #> [PostgreSQL: get JSON subcomponent (raw as string)] #>> [PostgreSQL: get JSON subcomponent (as JSON object)] ?: [short-ternary operator (Elvis operator)][note: checks true/false][note: sometimes || is equivalent (e.g. JavaScript)][WARNING: in some languages, checks non-null/null (a null-coalescing operator) e.g. Kotlin] ?? [null-coalescing operator][note: non-null/null] ... [spread/splat][note: Swift: also for closed ranges][note: Ruby: range (exclusive end)] .. [range][e.g. Haskell/Kotlin/Pascal/Perl/Ruby: inclusive end, e.g. C#/Rust: WARNING: exclusive end] ..< [range][e.g. Kotlin: range until, Swift: half-open range] ..= [range][e.g. Rust: inclusive end] : [range][e.g. R: inclusive end] . [member access][AutoHotkey/Perl/PHP: concatenate] ~= [AutoHotkey: RegExMatch] =~ [Ruby: RegEx match] !~ [Ruby: RegEx not match] :: [C++: scope qualifier (and for class out-of-line definitions: declare inside class, define elsewhere)][AutoHotkey: hotkey/hotstring][Kotlin: reference] # [directives][JavaScript: class private fields][Crystal/Ruby: string interpolation] ::<> [Rust: turbofish operator (specify a type, e.g. '::<i32>'/'::<String>')] %/% [R: floor division] role: comments: // [single-line comments] ; [single-line comments][e.g. AutoHotkey/FASM] # [single-line comments][e.g. Perl/PHP/Python/Ruby (PHP also uses //)] ' [single-line comments][e.g. Visual Basic] /* */ [multi-line comments (and single-line comments)][CSS comments] <!-- --> [HTML comments] :: [single-line comments][e.g. batch files] ''' [(3 apostrophes) bare string literals can be used as comments][e.g. Python] """ [bare string literals can be used as comments][e.g. Python] role: further symbols/operators: and [logical AND] or [logical OR] not [logical NOT] new [create object: create new instance of class] mod [modulo][Visual Basic has 'Mod' operator] in [is item in object] !in [is item not in object][e.g. Kotlin] , [separate statements] ; [separate statements] [ ] [get object value (aka subscript)] { } [scope][define object][noop][string interpolation] ( ) [group][note: '(mytype)' can be used for casting] @ [email addresses][R: member access] _ [often used as a variable name, during loops, for a variable that needs a name but isn't used][digit separator][Swift: unnamed parameter/label][sometimes used as a prefix for an object property name intended to be private] __ [Python: 'dunder' (double underscore): a prefix and suffix for object 'magic method' names (which are intended to be private)] : [object property assignment e.g. {"myprop": 123}] ?. [optional chaining operator] &. [Crystal/Ruby: safe navigation operator] " " [string literal][string literal concatenation (juxtaposition) e.g. AutoHotkey/C/C++/Python/Ruby] ' ' [string literal][char e.g. C/C++/C#/Java/Kotlin/Rust][string literal concatenation (juxtaposition) e.g. AutoHotkey/Python/Ruby] ' [C++: digit separator] \ [string escape character][Visual Basic: integer division (truncated division)] ` [JavaScript: template literals][AutoHotkey: string escape character] $ [string interpolation (inside string literals)][R: member access] role: RegEx: \.*?+[{|()^$ [12 characters that need escaping in RegEx generally] ^-]\ [4 characters that need escaping in a RegEx character class] $()*+-.?[\]^{| [14 characters listed above (^ and \ appear twice)] !"#%&',/:;<=>@_`}~ [18 characters not listed above from the 'classic 32'] $ [sometimes needs escaping when doing a RegEx replace] [note: PHP: preg_quote escapes the 14, and also these 7: '!#:<=>}'] [note: Python: re.escape escapes the 14, and also these 4: '#&}~'] [note: C#: Regex.Escape escapes the 12, and also this 1: '#'] [note: Kotlin: Regex.escape uses '\Q' and '\E' to escape, and correctly handles literal '\E']
Listed in Appendix A's Syntax Summary (pp. 214-219): unary: * & - ! ~ ++ -- binary: * / % + - >> << < > <= >= == != & ^ | && || ? : assignment: = += -= *= /= %= >>= <<= &= ^= |= also (scattered throughout Syntax Summary): ( ) , [ ] . -> ; { } : " " < > # (note: ':' in structs, '< >' with #include) not in Syntax Summary (but are in Appendix A): /* */ ' ' \ (note: '/* */' for comments, '' '' for characters, '\' for escape characters) (note: '//' was *not* available as a comment character until C99 (1999)) (note: when C++ was first released in 1985, it had both comment styles: '/* */' and '//')
a blueprint for ideal operators: + += [addition, *NOT* concatenation (safer to restrict '+' to numbers only)] - -= [subtraction] * *= [multiplication and spread operator (for function calls and definitions)] / /= [true division (i.e. int/int=float)] ~/ ~/= [C-style (truncated) integer division (e.g. Dart)] ~~/ ~~/= [floor division (author's proposal), least worst option so far] ** **= [exponentiation] . .= [concatenation, and member access] ~ & | ^ &= |= ^= [bitwise: not/and/or/xor] ! && || [logical: not/and/or][where && and || return an operand, not necessarily a bool] << >> >>> >>= <<= >>>= [bitshift: left/right (signed)/right (unsigned)] % %= [C-style (truncated) modulo] %% %%= [floor modulo (e.g. R)] ?? ??= [PERHAPS][null-coalescing operator] ?. [PERHAPS][optional chaining operator] a blueprint for ideal operators (further): ? : [ternary operator]['c ? x : y', where c can be any value, not necessarily a bool] ?: [PERHAPS][would be equivalent to 'x ? x : y' and to 'x || y'] == [equals] != [not equal][PERHAPS: case-insensitive not equals (e.g. AutoHotkey)] <> [not equal][note: != and <> would both be present] < > <= >= [less than/greater than, less than or equal to/greater than or equal to] = [assign][PERHAPS: case-insensitive equals (e.g. AutoHotkey)] := [assign] ++ -- [increment/decrement] <=> [comparison (spaceship operator)] !== [PERHAPS] === [PERHAPS] => [fat-arrow function] .. [range (inclusive end)][PERHAPS] ..< [range (exclusive end)][PERHAPS] ~= [RegExMatch (e.g. AutoHotkey)][PERHAPS] non-operators: // [comments] /* */ [multi-line comments (and single-line comments)] ; [no role][PERHAPS: comments (e.g. AutoHotkey)] \ [escape character] ` [no role][PERHAPS: escape character (e.g. AutoHotkey)][PERHAPS: template literals (e.g. JavaScript)] :: [PERHAPS][hotkey/hotstring (e.g. AutoHotkey)] # [directives][JavaScript: class private fields] , [separate statements] [ ] [get object value (aka subscript)] { } [scope, define object, noop] ( ) [group] _ [often used as a variable name][digit separator] " " [string literal] ' ' [string literal (but its use discouraged, prefer " ")] : [object property assignment, and part of ternary operators] also: spare binary operators that can be defined by 2-parameter functions: op_a to op_z [possible future operators (author's proposal), least worst option so far]
possible operators for C-style (truncated) integer division: i.e. the values (integers or floats) are divided as floats then truncated (towards 0) to the nearest integer: ~/ (and ~/=) (e.g. Dart) possible operators for floor division: i.e. the values (integers or floats) are divided as floats then floored (rounded down) to the nearest integer: // (and //=) is used by Python (but is often unavailable since it's used for comments) ~~/ (and ~~/=) (author's proposal) (the least worst option so far) _/ (and _/=) (author's proposal), but _ is often a variable name possible operators for true division: i.e. the values (integers or floats) are divided as floats, and a float is returned: / (i.e. ideally int/int would return a float, because it's more intuitive, but if int/int already returns an int, a new symbol is needed ...) /./ (author's proposal) (one of the least worst options so far) ../ (author's proposal) (one of the least worst options so far) (alternatively if int/int already returns an int, it could be prohibited, use ~/ if int/int is wanted) possible spare binary operators that can be defined by 2-parameter functions: i.e. if one programming language has an operator, and one doesn't, or if 2 languages use the same symbol, but the functionality differs, use a spare binary operator, and give it a function, and string replace the old operator with the spare operator, to preserve the code intact, instead of trying to refactor the code to use a custom binary function (which can create bugs): op_a to op_z (e.g. 'a % b' in language 1, 'a op_m b' in language 2)
'SymCommentMultDemo': Testing the following multi-line comment symbols: AutoHotkey: /* */ C++: /* */ C#: /* */ Crystal: [none] Excel: [none] Excel VBA: [none] Go: /* */ Java: /* */ JavaScript: /* */ Kotlin: /* */ PHP: /* */ Python: [none] R: [none] Ruby: =begin =end Rust: /* */ Scala: /* */ SQL (MySQL): /* */ SQL (PostgreSQL): /* */ SQL (SQLite): /* */ Swift: /* */ TESTS: note: for the tests below, use the language's multi-line comment symbols (e.g. /* */, =begin =end) note: try comments at the beginning, in the middle, and at the end, e.g.: /* */ print("hello") /* */ print("hello") /* */ see also: SymCommentMult TEST 1 (useful pattern to comment out the rest of the document): [worked: AutoHotkey/MySQL/SQLite] [failed: all other languages] /* comment TEST 2 (useful pattern for fixing/translating code one section at a time): [worked: AutoHotkey/MySQL/SQLite] [failed: all other languages] /* comment 1 /* comment 2 /* comment 3 TEST 3: [failed: all languages] */ TEST 4: [failed: all languages] */ */ */ TEST 5 (useful pattern for fixing/translating code one section at a time): [worked: all languages except Kotlin/PostgreSQL/Rust/Scala/Swift] [note: Kotlin: worked if at very bottom (with no trailing newline)] /* comment 1 /* comment 2 /* comment 3 */ TEST 6: [failed: all languages] [note: Kotlin: worked if at very bottom (with no trailing newline)] /* comment 1 /* comment 2 /* comment 3 */ */ TEST 7 (useful pattern for fixing/translating code one section at a time): [worked: all languages] [note: AutoHotkey: use: */ line break /*] [note: Ruby: use: =end line break =begin] [note: Python: replace /* with ''', and */ also with '''] /* comment 1 */ /* comment 2 */ /* comment 3 */ /* comment 4 */