I have a struct, which contains records returned from a query. I then
perform a loop which runs another query which adds more records to the
struct, but I would like to check whether the record already exists
before adding it, is there a way to search a struct, say by id, to check
the existance of said record before I add it?
What is the purpose of using a Struct? ActiveRecord objects already
have setter and getter methods.
you can just use a normal array and either uniq it or use Array#| (the
set union operator) like @collection | @new_records to save a bit.
Also note that a Hash is unordered.
Regards,
Rein
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.