Keywords Flashcards

Keywords in Ruby and what they do (36 cards)

1
Q

BEGIN

A

Run this block when the script starts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

END

A

Run this block when the script is done

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

alias

A

create another name for a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

and

A

Logical and, but lower priority than &&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

begin

A

Start a block, usually for exceptions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

break

A

break out of a loop right now

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

case

A

Case style conditional, like an if

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

class

A

Define a new class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

def

A

define a new function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

defined?

A

Is this class/function/etc. defined already?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

do

A

Create a block that maybe takes a parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

else

A

Else conditional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

elsif

A

Else if conditional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

end

A

Ends blocks, functions, classes, everything

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

ensure

A

Run this code whether an exception happens or not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

ensure

A

Run this code whether an exception happens or not

17
Q

for

A

For loop syntax. The .each syntax is preferred

18
Q

if

A

If conditional

19
Q

in

A

In part of for-loops

20
Q

module

A

Define a new module

21
Q

next

A

skip to the next element of a .each iterator

22
Q

not

A

logical not. But use ! instead

23
Q

or

24
Q

redo

A

Rerun a code block exactly the same

25
rescue
Run this code if an exception happens
26
retry
In a rescue clause, says to try the block again
27
return
Returns a value from a function
28
self
The current object, class, module
29
super
The parent of this class
30
then
Can be used with if optionally
31
undef
Remove a function definition from a class
32
unless
Inverse of if
33
until
Inverse of while, execute block as long as false
34
when
Part of case conditionals
35
while
while loop
36
yield
Pause and transfer control to the code block