Array Methods Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

what does Array#each_slice do?

A

it splices the array into slices of length n

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

how would you split an array into slices of a fixed length?

A

Array#each_slice

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

what does Array#each_cons do?

A

it will run a window of length n over an array, returning each slice that the window covers.

[0,1,2,3,4].each_cons(2) will return [[0,1],[1,2],[2,3],[3,4]]

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

how do you find all left-to-right says of numbers in an array, given length n?

A

Array#each_cons

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