Programming Language Cheat Sheets: Operators and Symbols

Strings Mathematics [BitXXX e.g. BitAnd, XXXDiv e.g. TrueDiv] Operators and Symbols General (Control Flow/Debugging) Dates Objects New Features Timelines Sections: Introduction By Role By Symbol 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.

Introduction

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. 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.

By Role

UFL: OpSpreadCall/OpSpreadReceive [spread operator (splat operator)][function call: 'spread' an array as multiple separate arguments][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: */* 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] Excel: [none] Excel VBA: [none] Go: ... [e.g. MyFunc(oArray...)] Java: [none] JavaScript: ... [e.g. MyFunc(...oArray)] [note: spread syntax] Kotlin: * [e.g. MyFunc(*oArray)] PHP: ... [e.g. MyFunc(...$oArray)] Python: * [e.g. MyFunc(*oArray)] [note: splat] R: [none] [can use: do.call(oFunc, as.list(oVec))] Ruby: * [e.g. MyFunc(*oArray)] Rust: [none] Scala: * [e.g. MyFunc(oArray*)] 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: works on tuples but not arrays] 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)] 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 =] Swift: ... [e.g. func MySum(_ oParams: Int...) -> Int] [note: ... is also used for closed ranges] UFL: OpTern [ternary operator]['c ? x : y' is preferable since it's clear/concise/common, else use alternative symbols like Raku ('c ?? x !! y')][a ternary function (e.g. 'Tern') is a lesser option since it can't do short-circuit Boolean evaluation][note: state if bool/parentheses needed][see also: IsTruthy] AutoHotkey: c ? x : y C++: c ? x : y C#: c ? x : y [WARNING: 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: evaluates both branches] Excel VBA: [none] [can use: IIf(c, x, y)] [note: c must be a bool or numeric] [WARNING: evaluates both branches] Go: [none] [MAJOR WARNING: in Go, a ternary operator is currently a 5-liner, or a 6-liner if also declaring a variable] Java: c ? x : y [WARNING: c must be a bool] JavaScript: c ? x : y Kotlin: if (c) x else y [WARNING: unusual operators] [WARNING: 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"))] R: if (c) x else y [also: ifelse(c, x, y)] [also: `if`(c, x, y)] 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] [WARNING: 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] [WARNING: c must be a bool] [note: can be used in expressions] [note: parentheses *are* needed] Swift: c ? x : y [WARNING: 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] AutoHotkey: || [note: AHK v2 onwards] C++: [none] [can use: a?a : b?b : c] C#: [none] [can use: (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)] [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: (a!=0) ? a : (b!=0) ? b : c] JavaScript: || Kotlin: [none] [can use: arrayOf(a, b, c).find{it!=0} ?: 0] [can use: if (a!=0) a else if (b!=0) b else c] PHP: ?: Python: or R: [none] [can use: if (vVar) vVar else vDefault] [can use: `if`(vVar, vVar, vDefault)] [note: an error occurs if NULL or a string is tested for truthiness] Ruby: || [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] [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: if(a!=0) a else if(b!=0) b else c] 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][see also: Array.Find] 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,vDefault)] 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))] 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 ;] Scala: ; 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] [though it is common to end lines with ;] Kotlin: [none] PHP: ; Python: [none] R: [none] Ruby: [none] Rust: ; Scala: [none] Swift: [none] UFL: SymEscape [string escape character][individual characters by frequency: nrt\'" abfv0 es$;?][see also: IntToStrCharEscapeDemo] 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 \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] 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] Swift: \ [\n \r \t \' \" \\ \0] [also (with further chars): \u] UFL: SymInterpolateDemo [string interpolation][see also: Format] AutoHotkey: [none] [can use: Format("Hello, {}!", name)] C++: [none] [can use: std::format("Hello, {}!", name)] [requires: #include <format>] [note: ' is used for chars] C#: $"Hello, {name}!" [note: ' is used for chars] Crystal: "Hello, #{name}!" [WARNING: # is a special character in string literals] [note: ' is used for chars] Excel: [none] Excel VBA: [none] Go: [none] [can use: fmt.Sprintf("Hello, %v!", name)] [note: ' is used for chars] Java: [none] [can use: String.format("Hello, %s!", name)] [note: ' is used for chars] JavaScript: `Hello, ${name}!` Kotlin: "Hello, ${name}!" [also: "Hello, $name!"] [WARNING: $ is a special character in string literals] [note: ' is used for chars] PHP: "Hello, ${name}!" [also: "Hello, $name!"] [WARNING: $ is a special character in string literals] [note: doesn't work with single quotes] Python: f"Hello, {name}!" [also: f'Hello, {name}!'] R: [none] [can use: sprintf("Hello, %s!", name)] Ruby: "Hello, #{name}!" [WARNING: # is a special character in string literals] [note: doesn't work with single quotes] Rust: [none] [can use: format!("Hello, {name}!")] [note: ' is used for chars] Scala: s"Hello, ${name}!" [also: s"Hello, $name!"] [note: ' is used for chars] Swift: "Hello, \(name)!" [note: ' is not used for strings or chars] UFL: OpPow [power (exponent)][see also: Pow] AutoHotkey: ** C++: [none] C#: [none] Crystal: ** Excel: ^ Excel VBA: ^ Go: [none] [can use: math.Pow(vNum1, vNum2)] [requires: import "math"] Java: [none] JavaScript: ** Kotlin: [none] PHP: ** Python: ** R: ** [also: ^] Ruby: ** Rust: [none] Scala: [none] Swift: [none] UFL: SymComment [single-line comment] 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: // Swift: // UFL: SymCommentMult [multi-line comments][note: also work as single-line comments] 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: /* */ Swift: /* */ UFL: OpConcat [concatenate][see also: StrConcat] AutoHotkey: . [also: string literal concatenation (and other types) (auto-concat) (e.g. '"abc" "def" 123' is equivalent to '"abcdef123"')] C++: + [WARNING: + for addition and concatenation] [also: string literal 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: string literal 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] Rust: + [WARNING: + for addition and concatenation] Scala: + [WARNING: + for addition and concatenation] Swift: + [WARNING: + for addition and concatenation] UFL: OpLTStr/OpGTStr [string comparison (less than/greater than)] AutoHotkey: [none] [can use: StrCompare()] C++: < > [e.g. ((std::string)"abc" < (std::string)"def")] [also (for char arrays): strcmp()] C#: [none] [can use: String.Compare()] Crystal: < > Excel: < > Excel VBA: < > Go: < > Java: [none] [can use: compareTo()] JavaScript: < > Kotlin: < > PHP: < > Python: < > R: < > Ruby: < > Rust: < > Scala: < > Swift: < > UFL: OpEquals [comparison (equality)][see also: StrEquals] AutoHotkey: == [note: 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: == JavaScript: == Kotlin: == [also (referential equality): ===] PHP: === [also (equal after type juggling): ==] Python: == R: == Ruby: == [also: eql (type-sensitive), equal (compares object IDs)] [e.g. 1.eql?(1.0)] [e.g. [].equal?([])] Rust: == Scala: == Swift: == UFL: OpNotEquals [comparison (not equals)] AutoHotkey: !== [note: case-insensitive: !=] 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: !=] Kotlin: != [also (referential equality negated counterpart): !==] PHP: !== [also (not equal after type juggling): != <>] Python: != R: != Ruby: != Rust: != Scala: != 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 Rust: i+=1 Scala: i+=1 Swift: i+=1 [FIXME] 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 Rust: i-=1 Scala: i-=1 Swift: i-=1 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] Swift: ___ [error] UFL: OpAssign [assign] 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: =] Ruby: = Rust: = Scala: = Swift: = [FIXME] 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] C++: && C#: && Crystal: && Excel: [none] [can use: AND(A1,B1)] Excel VBA: And Go: && Java: && JavaScript: && Kotlin: && PHP: && Python: and R: && Ruby: && Rust: && Scala: && Swift: && [FIXME] UFL: OpOr [logical or][for some languages: inputs must be bools][for some languages: output is bool, for others: first truthy value] AutoHotkey: || C++: || C#: || Crystal: || [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Excel: [none] [can use: OR(A1,B1)] Excel VBA: Or [note: bitwise-or] Go: || Java: || JavaScript: || Kotlin: || PHP: || Python: or R: || Ruby: || [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Rust: || Scala: || Swift: || 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] Swift: 0 != 0 || 123 != 0 [output: true] [note: '0 || 123' is invalid] [FIXME] UFL: OpNot [logical not][see also: IsTruthy] AutoHotkey: ! [also: not] [note: !/not have different operator precedences] C++: ! C#: ! Crystal: ! [MAJOR WARNING: in Crystal, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Excel: [none] [can use: NOT(vValue)] Excel VBA: [none] [WARNING: 'Not' in Excel VBA is bitwise-not] [can use: (vValue = 0)] Go: ! Java: ! JavaScript: ! Kotlin: ! PHP: ! Python: not R: ! Ruby: ! [MAJOR WARNING: in Ruby, only false/nil are considered falsy (e.g. 0 and "" are considered truthy)] Rust: [none] [WARNING: '!' in Rust is bitwise-not] [can use: (vValue == 0)] Scala: ! Swift: ! UFL: OpNotIntDemo [logical not applied to integers (e.g. !123)] AutoHotkey: 0 C++: 0 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 [WARNING: Excel lacks '!'] [note: NOT(123) returns FALSE] Excel VBA: error [WARNING: Excel VBA lacks '!'] [WARNING: 'Not' in Excel VBA is bitwise-not] [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: error [WARNING: Python lacks '!'] [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: '!' in Rust is bitwise-not] [note: (123 == 0) returns false] Scala: error [note: !true returns false] Swift: error [note: !true returns false] UFL: OpNotStrDemo [logical not applied to strings (e.g. !"abc")] AutoHotkey: 0 C++: 0 [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 [WARNING: Excel lacks '!'] [note: NOT() in Excel returns an error on strings] Excel VBA: error [WARNING: Excel VBA lacks '!'] [WARNING: 'Not' in Excel VBA is bitwise-not] [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: error [WARNING: Python lacks '!'] [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 [WARNING: '!' in Rust is bitwise-not] [note: ("abc" == "") returns false] Scala: error [note: !true returns false] Swift: error [note: !true returns false] UFL: OpNotNotIntDemo [logical not applied to integers twice (e.g. !!123)] AutoHotkey: 1 C++: 1 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 [WARNING: Excel lacks '!'] [note: NOT(NOT(123)) returns TRUE] Excel VBA: error [WARNING: Excel VBA lacks '!'] [WARNING: 'Not' in Excel VBA is bitwise-not] [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: error [WARNING: Python lacks '!'] [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: '!' in Rust is bitwise-not] [note: ((123 == 0) == false) returns true] Scala: error [note: !(!true) returns 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 C++: 1 [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 [WARNING: Excel lacks '!'] [note: NOT() in Excel returns an error on strings] Excel VBA: error [WARNING: Excel VBA lacks '!'] [WARNING: 'Not' in Excel VBA is bitwise-not] [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: error [WARNING: Python lacks '!'] [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 [WARNING: '!' in Rust is bitwise-not] [note: (("abc" == "") == false) returns true] Scala: error [note: !(!true) returns true] Swift: error [note: !(!true) returns true] [WARNING: error if attempt '!!': 'unary operators must not be juxtaposed'] [FIXME] UFL: OpSafeNav [or OpNullChain][safe navigation operator (optional chaining operator)][e.g. (from Wikipedia): name = article?.author?.name] AutoHotkey: [none] C++: [none] C#: ?. [null-conditional member access operator] Crystal: ___ [can use: '.try &.', e.g. a.try &.b.try &.c] Excel: [none] Excel VBA: [none] Go: [none] Java: [none] JavaScript: ?. [optional chaining operator] Kotlin: ?. [safe call operator] PHP: ?-> [null-safe operator] Python: [none] R: [none] Ruby: &. [safe navigation operator] Rust: [none] [can use (acts like a return if sees a None): ?] [also: oOpt.map] [also: oOpt.and_then] Scala: [none] Swift: ?. [optional chaining operator] [also (optional subscript operator): ?[vIndex].] [also (optional call): ?().] 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] [can use: BIN2DEC/OCT2DEC/HEX2DEC] Excel VBA: [none]/&O/&H [can use: WorksheetFunction.Bin2Dec] [note: Visual Basic 2017 has &B] Go: 0b/0o/0x Java: 0b/[none]/0x JavaScript: 0b/0o/0x Kotlin: 0b/[none]/0x PHP: 0b/0o/0x Python: 0b/0o/0x R: [none]/[none]/0x Ruby: 0b/0o/0x Rust: 0b/0o/0x Scala: [none]/[none]/0x Swift: 0b/0o/0x 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: _ Swift: _

By Symbol

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] 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 Swift: true division UFL: SymCharSlashSlash [//] 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 Swift: comment UFL: SymCharPct [%][note: typically C-style modulo (truncated modulo)][see also: Mod/FloorMod] AutoHotkey: ___ [can use (truncated modulo, ints/floats): Mod(vNum1, vNum2)] 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, ints/floats): vNum1 Mod vNum2] [WARNING: truncates operands before calculating] [WARNING (Mod operator): truncates operands before calculating (note: Excel's sheet function MOD does not do this)] 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: ints only] 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: ___ [can use (floor modulo, ints/floats): 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] Swift: truncated modulo [note: ints only] UFL: SymCharApos [' (single quotes) (apostrophes)] AutoHotkey: literal strings C++: characters [note: ' is also a numeric literal separator] C#: characters Crystal: characters Excel: ___ Excel VBA: comments Go: characters Java: characters JavaScript: literal strings Kotlin: characters PHP: literal strings Python: literal strings R: literal strings Ruby: literal strings Rust: characters Scala: characters Swift: ___ UFL: SymCharEq [=] AutoHotkey: equals [note: *case-insensitive* when comparing strings] C++: assign C#: assign Crystal: assign Excel: assign [also: equals (comparison)] [note: *case-insensitive* when comparing strings] Excel VBA: assign [also: equals (comparison) (case-sensitive 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 [also: <-] Ruby: assign Rust: assign Scala: assign Swift: assign 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 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: ___ Swift: ___ 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 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: ___ Swift: ___ UFL: SymCharLtGt [<>] AutoHotkey: ___ [deprecated: was available in AHK v1 (*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: was available in Python v2] R: ___ Ruby: ___ Rust: ___ Scala: ___ Swift: ___

Summary: Operators Across Multiple Languages

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] ~ & | ^ [bitwise: not/and/or/xor][^ is sometimes power][Visual Basic: & is concatenate][C++: & is also address-of] ! && || [logical: not/and/or][logical not (logical negation)][Swift: unwrap optional][Rust: WARNING: ! is also bitwise-not (and used for macro expansion)] ? : [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)][note: in Excel, % is equivalent to '/100'] 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] 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)] => [fat-arrow function][PHP: key-value pair definitions] -> [C++: member access (structure pointer operator)][Kotlin: lambda expression, declaring function types][PHP: property access] ?: [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][AutoHotkey: hotkey/hotstring][Kotlin: reference] # [directives] ::<> [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] _ [often used as a variable name, during loops, for a variable that needs a name but isn't used][numeric literal separator][Swift: unnamed parameter/label] : [object property assignment e.g. {"myprop": 123}] ?. [optional chaining operator] " " [literal string][string literal concatenation (juxtaposition) e.g. AutoHotkey/C/C++/Python/Ruby] ' ' [literal string][char e.g. C/C++/C#/Java/Kotlin/Rust][string literal concatenation (juxtaposition) e.g. AutoHotkey/Python/Ruby] ' [C++: numeric literal separator] \ [string escape character][Visual Basic: integer division] ` [JavaScript: template literals][AutoHotkey: string escape character] $ [string interpolation (inside literal strings)] 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...\E' to escape, and correctly handles literal '\E']

Operators and Symbols Listed in: The C Programming Language (1978)

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 '//')

The Universal Function Library Project: Details

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] , [separate statements] [ ] [get object value (aka subscript)] { } [scope, define object, noop] ( ) [group] _ [often used as a variable name][numeric literal separator] " " [literal string] ' ' [literal string (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]

Inventing Operators

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)

Multi-Line Comments

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: /* */ 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] [failed: all other languages] /* comment TEST 2: [worked: AutoHotkey] [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/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: also worked with Python, replace /* with ''', and */ with '''] /* comment 1 */ /* comment 2 */ /* comment 3 */ /* comment 4 */