Easy Category Ruby Questions Flashcards

1
Q

What is (&:to_i) shorthand for?

A

something.map { |char| char.to_i }

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

Explain method unshift and which class it modifies

A
unshift(obj, ...) → ary
Prepends objects to the front of self, moving other elements upwards. Use on class Array#prepend or Array#unshift

https://ruby-doc.org/core-2.5.0/Array.html#method-i-unshift

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

What does the method divmod do and to which class does it apply?

A

divmod(numeric) → array
Returns an array containing the quotient and modulus obtained by dividing num by numeric. Class: Numeric

https://ruby-doc.org/core-2.5.3/Numeric.html#method-i-divmod

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