• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/32

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

32 Cards in this Set

  • Front
  • Back
  • 3rd side (hint)

BEGIN

Run this block when the script starts.

BEGIN { puts "hi" }

END

Run this block when the script is done.

END { puts "hi" }

alias

Create another name for a function

alias X Y

begin

Start a block, usually for exceptions.

begin end

break

break out of a block right now.

while true; break; end

case

Case style conditional, like an if.

case X; when Y; else; end

class

Define a new class.

class X; end

def

Define a new function.

def X(); end

defined?

Is this class/function/etc already defined?

defined? Class == "constant"

do

Create a block that maybe takes a parameter.

(0..5) .each do |x| puts x end

else

Else conditional.

if x; else; end

elsif

Else if conditional.

if x; elsif Y; else; end

end

Ends blocks, functions, classes, everything.

begin end # many others

ensure

Run this code whether an exception happens or not.

begin ensure end

for

For loop syntax. The .each syntax is preferred.

for X in Y; end

if

If conditonal.

if X; end

in

In part of for-loops.

for X in Y; end

module

Define a new module.

module X; end

next

Skip to the next element of a .each iterator.

(0..5) .each {|y| next }

redo

Rerun a code block exactly the same.

(0..5) .each {|i| redo if i >2 }

rescue

Run this code if an exception happens.

begin rescue X; end

retry

In a rescue clause, says to try the block again.

(0..5) .each {|i| redo if i >2 }

return

Returns a value from a function. Mostly optional.

return X

self

The current object, class, or module.

defined? self == "self"

super

The parent class of this class.

super

then

Can be used with if optionally.

if true then puts "hi" end

undef


Remove a function definition from a class.

undef X

unless

Inverse of if.

unless false then puts "not" end

until

Inverse of while, execute block as long as false.

until false; end

when

Part of case conditionals.

case X; when Y; else; end

while

While loop.

while true; end

yield

Pause and transfer control to the code block.

yield