# frozen_string_literal
# encoding
__END__
- Singleton literals
nil
true
false
- Numeric literals
123
123.0
123r
123i
- String-likes
/re/
(w/ or w/o interpolation)"str"
(w/ or w/o interpolation):"sym"
(w/ or w/o interpolation):sym
#{expr}
#@var
%w[...]
and its family<<EOF
and its family
- Constructor syntaxes
[elems]
{ entries }
..
/...
- Variable-likes
my_var
MyConst
::
(prefix)::
(infix)@var
@@var
$foo
$foo
$"
etc.$-a
etc.$&
$1
self
__ENCODING__
__FILE__
__LINE__
it
_1
- Calls
meth
obj.meth
(also&.
and::
)obj.(args)
(also&.
and::
)obj[idx]
`cmd`
(w/ or w/o interpolation)-> { body }
for lhs in arr
super
(which issuper(...)
)super(args)
- Operators
&&
/and
&&=
||
/or
||=
!
/not
(has special semantics in old Rubies)- Ordinary operator expressions (which is method call)
!
/~
/+
(unary) /-
(unary)**
*
//
/%
+
/-
<<
/>>
&
|
/^
>
,>=
,<
,<=
<=>
,==
,!=
,===
,=~
,!~
not
(alias of!
)
- Operator assignments (for binary non-predicate operators)
**=
*=
//=
/%=
+=
/-=
<<=
/>>=
&=
|=
/^=
- Declarations
def meth
(also endless variants)def (recv).meth
(also endless variants)class
class <<expr
module
alias
undef
- Controls
begin
if
/unless
(either prefix or infix)else
/elsif
while
/until
(either prefix or infix)case
/when
/else
(for classic switching)case
/in
/else
(for pattern-based switching)ensure
rescue
rescue
(infix operator)return
break
next
yield
redo
retry
END
BEGIN
- Arguments (also in Arrays and Hashes)
arg_expr
as in arguments*arr
key => value
key: value
**kwargs
&my_block
do |params| end
/{ |params| }
...
as in arguments
- Predicates
defined?
expr in pat
expr => pat
- Implicit syntaxes
- Implicit array in assignment RHS
if a..b
(i.e. flip-flop)if /re/
(a.k.a. match last)/(?<my_var>...)/ =~ val
(note the capture)
- Variable-likes
my_var
my_param = default_value
my_kwparam:
my_kwparam: default_value
MyConst
(also note::
)# shareable_const_value: literal
@var
@@var
$var
(except$1
and$&
variants)
- Calls
obj.attr
obj[idx]
- Splats
*args
**kwargs
**nil
...
- Multi
lhs1, lhs2
- Decl
do |x, y; z|
- Implicit syntaxes
- implicit
it
capture (when the variable is used in the block body) - implicit
_1
capture (when the variable is used in the block body) - implicit
*
(when the multi LHS ends with,
)
- implicit
|
[elems]
[*left, elems, *right]
my_var
{ entries }
^(expr)
/^my_var