0
陣列我有這樣的代碼:紅寶石:按一個foat場
response = Place.all
nearPlaces = []
for el in response
distance = el.distance_to([41.9097306,12.2558141])
if distance < 20
el.distance = distance
nearPlaces.push(el)
end
end
orderPlaces = nearPlaces.sort_by{|e| e[:distance]}
但陣列不受距離整理歸檔......什麼建議嗎?
我有此錯誤=>'語法錯誤,意想不到&' – SaroVin
@SaroVin是不可能:) –
詳情=>'_controller.rb:23:語法錯誤,意想不到&orderPlaces = nearPlaces.sort_by { &:distance} ^' – SaroVin