Symbol review Flashcards
\
Escape backslash
'
Escape single-quote (‘)
"
Escape double-quote (“)
\a
Escape bell
\b
Escape backspace
\f
Escape formfeed
\n
Escape newline
\r
Escape carriage
\t
Escape Tab (TAB)
\v
Escape vertical tab
BEGIN
Run this block when the script starts.
END
Run this block when the script is done.
alias
Create another name for a function.
and
Logical and, but lower priority than &&.
begin
Start a block, usually for exceptions.
break
Break out of a loop.
case
Case style conditional, like an if.
class
Define a new class.
def
Define a new function.
defined?
Is this class/function/etc. defined already?
do
Create a block that maybe takes a parameter.
else
Else conditional.
elsif
Else if conditional
end
Ends blocks, functions, classes, etc.
ensure
Run this code whether an exception happens or not.
for
For loop syntax. *The .each syntax is preferred.
if
If conditional.
in
In part of for-loops.
module
Define a new module.
next
Skip to the next element of a .each iterator.
not
Logical not. *use ! instead.
or
Logical or.
redo
Rerun a code block exactly the same.
rescue
Run this code if an exception happens.
retry
In a rescue clause, says to try the block again.
return
Returns a value from a function. *Mostly optional.
self
The current object, class, or module.
super
The parent class of this class.
then
Can be used with if optionally.
undef
Remove a function definition from a class.
unless
Inverse of if.
until
Inverse of while, execute block as long as false.
when
Part of case conditionals.
while
While loop.
yield
Pause and transfer control to the code block.
true
True boolean value.
false
False boolean value.
nil
Represents “nothing” or “no value”.
strings
Stores textual information.
numbers
Stores integers.
floats
Stores decimals.
arrays
Stores a list of things.
hashes
Stores a key=value mapping of things.
+
Add
-
Subtract
*
Multiply
**
Power of
/
Divide
%
Modulus
>
Greater then
.
Dot access
::
colon access
[ ]
List brackets
!
Not
<
Less then
> =
Greater then equal
<=
Less then equal
==
Comparison
===
Equality
!=
Not equal
&&
Logical and (higher precedence)
||
Logical or (higher precedence)
..
Range inclusive
…
Range non-inclusive
@
Object scope
@@
Class scope
$
Global scope
What does a||b do?
Check if a is either false or nill, if it is return b. Otherwise return a
What will this return if count is nill?
count ||= 37
count = 37
What will this return if count is 21?
count ||= 37
count = 21