Use default value if item not found in array

139 viewsrubyselectruby select
0

So I’ve got my code trying to select an object from an array of objects, and if the object isn’t found, I want to create my defaults.

lead_time = lead_times.select{|d| LeadTimeProfile.new unless d.day_of_week == day }

however, from what I can tell, this is not returning me the devault LeadTimeProfile.

is there a way of doing this? Or have I got it right?