Keywords Flashcards

Keywords in Ruby and what they do

You may prefer our related Brainscape-certified flashcards:
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

A

Logical or.

24
Q

redo

A

Rerun a code block exactly the same

25
Q

rescue

A

Run this code if an exception happens

26
Q

retry

A

In a rescue clause, says to try the block again

27
Q

return

A

Returns a value from a function

28
Q

self

A

The current object, class, module

29
Q

super

A

The parent of this class

30
Q

then

A

Can be used with if optionally

31
Q

undef

A

Remove a function definition from a class

32
Q

unless

A

Inverse of if

33
Q

until

A

Inverse of while, execute block as long as false

34
Q

when

A

Part of case conditionals

35
Q

while

A

while loop

36
Q

yield

A

Pause and transfer control to the code block