methods Flashcards

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

What’s the difference between puts and print?

A

When using puts the next thing printed to the screen will be on the next line. With print the next thing will be on the same line.

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

What does .length do?

A

Returns the length of the string.

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

What does .count do?

A

It counts and returns the number of items in an array. When given with a index value parameter it returns the value in that index value within the array. When given with an equation parameter it will return the number of values within the array that fulfill the equation.

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

What do .drop and .drop_while do?

A

The .drop will take out the value in an array with the index value given as a parameter. Then it will return an array with what is left. The .drop_while will drop the values that meet the parameter and return an array of what’s left in the array.

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

What does .each do?

A

It iterates over any array or hash and does the specified actions to each value/key.

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

What does .find do?

A

Finds and returns the first value that meets the specifications.

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

What does .find_all do?

A

It returns an array of all the values that met the specifications.

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

What does .group_by do?

A

It iterates through the values and separates them into what they got for an answer to the parameters. It them returns a hash with the answer as the key and the values that got that answer in another array as the value.

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

What do .max, and .min do.

A

The .max method returns the highest number or farthest in the alphabet alphabetically value. The .min method does the opposite. When given a parameter they will give you that many returns in an array.

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

What does .all? do?

A

It checks to see if all the value provided meet the arguments requirements. It then returns true or false.

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

What does .any? do?

A

It checks to see if any of the values provided meet the arguments requirements. It then returns true or false.

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

What does .none? do?

A

It checks to see if none of the values provided meet the arguments requirements. It then returns true or false.

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

What does .all? do?

A

It checks to see if all the value provided meet the arguments requirements. It then returns true or false.

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

What does .any? do?

A

It checks to see if any of the values provided meet the arguments requirements. It then returns true or false.

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

What does .none? do?

A

It checks to see if none of the values provided meet the arguments requirements. It then returns true or false.

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

What does .partition do?

A

It will split values into arrays depending on the arguments equation. It then returns those arrays.

17
Q

What does .even? do?

A

Returns true if the number given is even. Returns false if odd.

18
Q

What does .reverse_each do?

A

It iterates over values and sorts them reverse alphabetically or high to low values for numbers.

19
Q

What does .sort do?

A

It sorts the value alphabetically or smallest to largest for numbers. You can also specify how to sort them in the parameters.

20
Q

What does .times do?

A

It repeats the action given the amount of times specified in the parameter.