methods Flashcards
What’s the difference between puts and print?
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.
What does .length do?
Returns the length of the string.
What does .count do?
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.
What do .drop and .drop_while do?
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.
What does .each do?
It iterates over any array or hash and does the specified actions to each value/key.
What does .find do?
Finds and returns the first value that meets the specifications.
What does .find_all do?
It returns an array of all the values that met the specifications.
What does .group_by do?
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.
What do .max, and .min do.
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.
What does .all? do?
It checks to see if all the value provided meet the arguments requirements. It then returns true or false.
What does .any? do?
It checks to see if any of the values provided meet the arguments requirements. It then returns true or false.
What does .none? do?
It checks to see if none of the values provided meet the arguments requirements. It then returns true or false.
What does .all? do?
It checks to see if all the value provided meet the arguments requirements. It then returns true or false.
What does .any? do?
It checks to see if any of the values provided meet the arguments requirements. It then returns true or false.
What does .none? do?
It checks to see if none of the values provided meet the arguments requirements. It then returns true or false.