http://ruby-doc.org/core-2.2.0/Array.html#method-i-compact
compact → new_aryclick to toggle source
Returns a copy of self
with all nil
elements removed.
[ "a", nil, "b", nil, "c", nil ].compact #=> [ "a", "b", "c" ]
render :json => { :videos => result_videos.compact.map do |video| if video.class == CmsTvIVideo if video.video_type == "live" { :title => video.title, :live_name => video.live_name, :live_id=> video.live_id, :big_horizontal_image => video.res_img_l, :middle_horizontal_image => video.res_img_m, :big_vertical_image => video.res_img_s, :middle_vertical_image => video.middle_vertical_image, :mtype => "live" }
时间: 2024-10-13 20:07:20