w2d1 revisions Flashcards

1
Q

What Git commands should be entered into your PC every morning?

A

git config –local user.name= ‘pair1 + pair2’

git config –local user.email = ‘pair1 + pair2@appacademy.io’

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

What tense should be used for commits?

A

Present tense

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

What does the Comparable#between? function do?

A

Checks if a number lies within a given range, inclusive:

2.between?(0..2)
=>true

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

What does Array#flatten do?

A

Reduces a multidimensional array to a 1 dimensional array.

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

Can an instance variable end in a ‘?’

A

No; but you can define a function to do so, since you can’t simply use attr_reader:

@sitting = false

def sitting?
@sitting
end

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

What is going on the following function:

def neighbors 
     adjacent_coords = DELTAS.map do |(dx, dy)| 
       [pos[0] + dx, pos[1] + dy] 
     end.select do |row, col| 
       [row, col].all? do |coord| 
         coord.between?(0, @board.grid_size - 1) 
       end 
     end 
adjacent_coords.map { |pos| @board[pos] }     end
A

First, it gets an array of all 8 adjacent spaces where the coordinates are valid. Then, it retrieves the tile objects themselves given these coordinates.

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

What is an easy way to flip a Boolean?

A

mybool = !mybool

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

Say we have a 2 element array names ‘arry’; what is the easiest way to retrieve the values from that array and store them in variables?

A

first, second = arry

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

What does the following code do:

File.write(filename, YAML.dump(self))

A

Within a class, writes a YAML representation of that class to a file.

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

What is an easy way to retrieve a YAML object from a file?

A

YAML.load_file(filename)

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