带参数的条件复杂

时间:2013-01-24 10:59:41

标签: ruby-on-rails ruby ruby-on-rails-3 google-geocoder

if @near.nil?
  loc, @near, found = get_user_geolocation
else
  loc = GeoKit::Geocoders::GoogleGeocoder.geocode(@near)
  found = loc.success
  @near = loc.full_address
end

在第一个if部分,发生了什么?我的语法可能不太好,但它让我很好奇。 提前谢谢。

2 个答案:

答案 0 :(得分:5)

请参阅Multiple Assignment

> a,b,c = [10,20,30] # or a,b,c = 10,20,30
> a => 10 
> b => 20 
> c => 30 

答案 1 :(得分:1)

get_user_geolocation方法返回三个值:loc@nearfound