I have @comments which is either 0 -XXXX number of comments from the DB.
I need this @comments as is as it is used in multiple places.
In one place I need @comments but minus the last record, if any.
How can I do that? w/o rehitting the db?
As already mentioned, @comments.pop
will do the job. Another option is to use a range to select which items from the array to use:
@comments[0..-2]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With