The "Missing:"s below indicate that an entry is incomplete.
| foo ... end where foo in { if, do, ... } | block (grouping statements, especially when statements are not expressions) |
| \ | breaking lines (useful when end-of-line and/or indentation has a special meaning) |
| # | commenting (until end of line) |
| < > <= >= | comparison |
| a <=> b | comparison (returns 3 values (i.e. inferior, equal or superior)) |
=begin ... =end | documentation comment |
| == != | equality / inequality (deep) |
| GC.start | force garbage collection |
| ( ... ) | grouping expressions |
| begin ... end | grouping expressions |
| __LINE__ __FILE__ | information about the current line and file |
| eval | runtime evaluation |
| case-sensitive | tokens (case-sensitivity (keywords, variable identifiers...)) |
| [A-Z][_a-zA-Z0-9]* | tokens (constant regexp (if different from variable identifier regexp)) |
| [_a-zA-Z][_a-zA-Z0-9]*[!?]? | tokens (function identifier regexp (if different from variable identifier regexp)) |
| CamelCase for modules and classes, ALL_CAPS for constants, underscores for functions, variables, ... | tokens (if case sensitive, what is the standard way for scrunching together multiple words) |
| [_a-z][_a-zA-Z0-9]* | tokens (variable identifier regexp) |
| = | variable assignment or declaration (both) |
| {|a, b| ... } (24) | anonymous function |
| proc {|a, b| ...} | anonymous function |
| lambda {|a, b| ...} | anonymous function |
| f(a,b,...) | function call |
| f[a,b,...] or f.call(a,b,...) | function call |
| f | function call (with no parameter) |
| f[] or f.call | function call (with no parameter) |
| method_missing | function called when a function is not defined (in dynamic languages) |
| def f(para1, para2, ...) ... end | function definition |
| return | function return value (breaks the control flow) |
| no syntax needed | function return value (function body is the result) |
| caller | runtime inspecting the caller information |
| next / break (36) | breaking control flow (continue / break) |
| redo / retry | breaking control flow (redo / retry) |
| return | breaking control flow (returning a value) |
| callcc | call-with-current-continuation |
| rescue | exception (catching) |
| ensure | exception (cleanup: code executed before leaving) |
| retry | exception (retrying: after catching an exception, tell the snippet to be re-run) |
| raise | exception (throwing) |
| if c then b end | if_then |
| b if c | if_then |
| if c; b end | if_then |
if c b end | if_then |
| if c then b1 else b2 end | if_then_else |
| case when c; b1 when c2; b2 else b3 end | if_then_else |
| c ? b1 : b2 | if_then_else |
if c b1 elsif c2 b2 else b3 end | if_then_else |
| begin expr end until cond | loop (do something until condition) |
| 10.downto(1) {|i| expr } | loop (for each value in a numeric range, 1 decrement) |
| (1..10).each {|i| expr } | loop (for each value in a numeric range, 1 increment (see also the entries about ranges)) |
| 1.upto(10) {|i| expr } | loop (for each value in a numeric range, 1 increment (see also the entries about ranges)) |
| (1..10).step(2) {|i| expr } | loop (for each value in a numeric range, free increment) |
| loop | loop (forever loop) |
| while (cond) expr | loop (while condition do something) |
case val when v1; expr1 when v2, v3; expr23 else expr_else end | multiple selection (switch) |
| ; | sequence |
| end-of-line | sequence |
| super | accessing parent method |
| class | class declaration |
| self | current instance |
| class | get the type/class corresponding to an object/instance/value |
| respond_to? | has the method |
| class child < parent end | inheritance |
| object.method(para) | method invocation |
| object.method | method invocation (with no parameter) |
| methods | methods available |
| o.clone (42) | object cloning |
| class_name.new(...) | object creation |
| is_a? kind_of? | testing class membership |
| module P ... end | declare |
| append_features | declare (selective export) |
| include or even extend | import (everything into current namespace) |
| require "p" | import (package (ie. load the package)) |
| . | package scope |
| s[n] | accessing n-th character |
| chr | ascii to character |
| ?z | character "z" |
| s[0] | character to ascii |
| to_s, to_str, inspect, String() | convert something to a string (see also string interpolation) |
| * | duplicate n times |
| s[n..m] | extract a substring |
| s[n,len] | extract a substring |
| index | locate a substring |
| rindex | locate a substring (starting at the end) |
| all strings allow multi-line strings | multi-line |
| Marshal.dump | serialize (marshaling) |
| simple print (on any objects) | |
| p (57) | simple print (on any objects) |
| puts (58) | simple print (on any objects) |
| printf | simple print (printf-like) |
| sprintf | sprintf-like |
| % | sprintf-like |
| + | string concatenation |
| == != | string equality & inequality |
| equal? | string equality & inequality |
| length | string size |
| size | string size |
| "\n" | strings (end-of-line (without writing the real CR or LF character)) |
| '...' | strings (verbatim) |
| <<'MARK' ... MARK | strings (verbatim) |
| %q(...(...)...), %q[...], %q{...}, %q<...>, %q/.../ | strings (verbatim) |
| "... #{v} ..." "... #$v ..." "... #@v ..." "... #@@v ..." | strings (with interpolation) |
| <<MARK ... #{v} ... MARK | strings (with interpolation) |
| %Q(...(... #{v} ...)...), %Q[...], %Q{...}, %Q<...>, %Q/.../ | strings (with interpolation) |
| Marshal.load | unserialize (un-marshaling) |
| upcase / downcase | upper / lower case character |
| upcase / downcase | uppercase / lowercase / capitalized string |
| false / nil | false value |
| ! | logical not |
| not | logical not |
| || / && | logical or / and (short circuit) |
| or / and | logical or / and (short circuit) |
| true / anything not false | true value |
| transpose | 2 lists from a list of couples |
| a.insert(i, e) | adding an element at index (side-effect) |
| unshift | adding an element at the beginning (list cons) (side-effect) |
| push | adding an element at the end (side-effect) |
| inject | f(... f(f(init, e1), e2) ..., en) |
| find | find an element |
| detect | find an element |
| each | for each element do something |
| for v in l ... | for each element do something |
| shift | get the first element and remove it |
| pop | get the last element and remove it |
| member? | is an element in the list |
| include? | is an element in the list |
| any? | is the predicate true for an element |
| all? | is the predicate true for every element |
| each_with_index | iterate with index |
| join | join a list of strings in a string using a glue string |
| l * glue | join a list of strings in a string using a glue string |
| find_all | keep elements matching |
| select | keep elements matching |
| reject | keep elements matching |
| a[-1] | last element |
| + | list concatenation |
| [ a, b, c ] | list constructor |
| flatten | list flattening (recursive) |
| zip | list of couples from 2 lists |
| transpose | list of couples from 2 lists |
| to_a | list out of a bag |
| size | list size |
| length | list size |
| a[i] | list/array indexing |
| slice | list/array indexing |
| assoc | lookup an element in a association list |
| uniq | remove duplicates |
| reverse | reverse |
| min / max | smallest / biggest element |
| sort | sort |
| sort_by | sort |
| partition | split a list in 2 based on a predicate |
| map | transform a list (or bag) in another one |
| collect | transform a list (or bag) in another one |
| a or [a] | computable tuple (these are a kind of immutable lists playing a special role in parameter passing) (1-uple) |
| [] | computable tuple (these are a kind of immutable lists playing a special role in parameter passing) (empty tuple) |
| *t | computable tuple (these are a kind of immutable lists playing a special role in parameter passing) (using a tuple for a function call) |
| fetch | dictionary (access: read) |
| h[k] | dictionary (access: read/write) |
| store | dictionary (access: write) |
| { a => b, c => d } | dictionary (constructor) |
| { a, b, c, d } | dictionary (constructor) |
| Hash[ a, b, c, d ] | dictionary (constructor) |
| has_key?, include?, key?, member? | dictionary (has the key ?) |
| keys | dictionary (list of keys) |
| values | dictionary (list of values) |
| delete | dictionary (remove by key) |
| nil | optional value (null value) |
| v | optional value (value) |
| a ... b | range (inclusive .. exclusive) |
| a .. b | range (inclusive .. inclusive) |
| . | record selector |
| a, b, c | tuple constructor |
| + / - / * / / | addition / subtraction / multiplication / division |
| & / | / ^ | bitwise operators (and / or / xor) |
| << / >> | bitwise operators (left shift / right shift / unsigned right shift) |
| ~ | bitwise operators (negation) |
| divmod | euclidian division (both quotient and modulo) |
| ** | exponentiation (power) |
| log / log10 | logarithm |
| remainder | modulo (modulo of -3 / 2 is -1) |
| % | modulo (modulo of -3 / 2 is 1) |
| modulo | modulo (modulo of -3 / 2 is 1) |
| - | negation |
| 1000.0, 1E3 | numbers syntax (decimals) |
| 1_000, 10_00, 100_0 | numbers syntax (integer thousand-seperator) |
| 0b1, 07, 0xf | numbers syntax (integers in base 2, octal and hexadecimal) |
| 1000 | numbers syntax (integers) |
| mathematical | operator priorities and associativities (addition vs multiplication) |
| mathematical | operator priorities and associativities (exponentiation vs negation (is -3^2 equal to 9 or -9)) |
| rand | random (random number) |
| srand | random (seed the pseudo random generator) |
| sqrt / exp / abs | square root / e-exponential / absolute value |
| sin / cos / tan | trigonometry (basic) |
| asin / acos / atan (88) | trigonometry (inverse) |
| to_i, Integer() / round / floor / ceil | truncate / round / floor / ceil |