I just tried to run some code that looked like this
def get_proj4(srid, type=nil)
type.downcase! if type
case type
when nil || "epsg"
open("http://spatialreference.org/ref/epsg/#{srid}/proj4/").read
when "esri"
open("http://spatialreference.org/ref/esri/#{srid}/proj4/").read
end
end
and it didn't run properly, returning nil every time. wrapping the nil || "epsg"
in parentheses didn't work either
It turns out ruby wouldn't allow me to use the ||
operator in this
Now I assume ruby takes the case/when method and ultimately breaks it down into a group of conditionals looking something like
x = type
if x == (nil || "epsg")
y = ...runs code...
elsif x == "esri"
y = ...
end
x = nil
y
but obviously it does not. What's going on here?
Thanks