Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- answers = [{answer_open: "Foo"}, {answer_image: ""}, {answer_image: "Bar"}]
- array = []
- answers.each do |a|
- if a[:answer_open] != ""
- array << a[:answer_open]
- else
- array << nil
- end
- if a[:answer_image] != ""
- array << a[:answer_image]
- else
- array << nil
- end
- end
- p array # ["Foo", nil, nil, nil, nil, "Bar"]
- # expecting ["Foo", nil, "Bar"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement