🕵️♀️ Task
When called on an ActiveRecord::Relation
, .first
returns the first record from the collection. If the collection is empty, .first
returns nil
.
You can optionally pass an Integer
argument to .first
. This will return n
number of records from the ActiveRecord::Relation
. If the collection is empty when you pass an argument, .first
returns an empty Array
.
Similar methods exist for second
, third
, fourth
, fifth
, forty_two
, last
, second_to_last
, and third_to_last
.